当前位置: 首页>>代码示例>>C#>>正文


C# Object.ToString方法代码示例

本文整理汇总了C#中System.Object.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Object.ToString方法的具体用法?C# Object.ToString怎么用?C# Object.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Object的用法示例。


在下文中一共展示了Object.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckDataType

        public static Boolean CheckDataType(Object value, FzDataTypeEntity dataType)
        {
            try
            {
                switch (dataType.DataType)
                {
                    case "Int16": Int16 a = 0; return (Int16.TryParse(value.ToString(), out a));
                    case "Int32": Int32 b = 0; return (Int32.TryParse(value.ToString(), out b));
                    case "Int64": Int64 c = 0; return (Int64.TryParse(value.ToString(), out c));
                    case "Byte": Byte d = 0; return (Byte.TryParse(value.ToString(), out d));
                    case "String": return true;
                    case "DateTime": return true;//DateTime e = DateTime.Today; return (DateTime.TryParse(value.ToString(), out e));
                    case "Decimal": Decimal f = 0; return (Decimal.TryParse(value.ToString(), out f));
                    case "Single": Single g = 0; return (Single.TryParse(value.ToString(), out g));
                    case "Double": Double h = 0; return (Double.TryParse(value.ToString(), out h));
                    case "Boolean":
                        if (value.ToString().ToLower() == "true" || value.ToString().ToLower() == "false") return true;
                        else return false;//Boolean k = true; return (Boolean.TryParse(value.ToString(), out k));
                    case "Binary": return (IsBinaryType(value));
                    case "Currency": return (IsCurrencyType(value));
                    case "UserDefined": return (dataType.DomainValues.Contains(value.ToString()));
                }
            }
            catch (Exception ex)
            {
                return false;
            }

            return false;
        }
开发者ID:ltvinh,项目名称:FRDB-SQLite,代码行数:30,代码来源:FzDataTypeDAL.cs

示例2: CDcml

 public static decimal CDcml(Object xobjObject)
 {
     decimal result;
     if (xobjObject == null || !decimal.TryParse(xobjObject.ToString(), out result) || xobjObject == DBNull.Value || xobjObject.ToString() == "")
         return 0;
     else return Convert.ToDecimal(xobjObject);
 }
开发者ID:FunesLisseth,项目名称:ProyectoSD,代码行数:7,代码来源:Validator.cs

示例3: set

 public void set(String field, Object value)
 {
     if (!list.ContainsKey(field))
         list.Add(field, value.ToString());
     else
         list[field] = value.ToString();
 }
开发者ID:ashokkn,项目名称:QBSilk4NetWhiteFramework,代码行数:7,代码来源:Properties.cs

示例4: Batch

        public Batch(String regionDir, String worldName, String dimensionName, bool replace, Object biome1, Object biome2, long worldSeed)
        {
            this.regionDir = regionDir;
            this.replace = replace;
            this.biome1 = biome1;
            this.biome2 = biome2;
            this.worldSeed = worldSeed;

            InitializeComponent();

            int before = lblPrompt3.Bottom;
            lblPrompt.MaximumSize = new Size(this.Width - lblPrompt.Left * 2, 0);
            lblPrompt2.MaximumSize = lblPrompt.MaximumSize;
            lblPrompt3.MaximumSize = lblPrompt.MaximumSize;
            if (!replace)
            {
                String b = String.Format(biome1 is BiomeType ? BIOMESTRING : MCSTRING, biome1.ToString());
                lblPrompt.Text = String.Format(PROMPTFILL, worldName, dimensionName, b);
                btnGo.Text = "Fill All Regions";
            }
            else
            {
                String b1 = String.Format(BIOMESTRING, biome1.ToString());
                String b2 = String.Format(biome2 is BiomeType ? BIOMESTRING : MCSTRING, biome2.ToString());
                lblPrompt.Text = String.Format(PROMPTREPLACE, worldName, dimensionName, b1, b2);
                btnGo.Text = "Replace All Regions";
            }

            lblPrompt2.Top = lblPrompt.Bottom + 10;
            lblPrompt3.Top = lblPrompt2.Bottom + 10;

            this.Height = this.Height + (lblPrompt3.Bottom - before);

            this.CancelButton = btnCancel;
        }
开发者ID:mblaine,项目名称:BiomePainter,代码行数:35,代码来源:Batch.cs

示例5: Dispatch

        public void Dispatch(Object @event)
        {
            //remember to use datetime.now to set an unique value for this event.
            _logger.SetOpType("event", @event.GetType().FullName + " " + DateTime.Now.ToString());

            _logger.Info("[evt dispatcher] dispatching event " + @event.ToString());
            var eventType = @event.GetType();
            var handlerInvokerList = _domainEventHandlerCatalog.GetAllHandlerFor(eventType);
            _logger.Debug("[evt dispatcher] dispatching event " + @event.ToString() + " found " + handlerInvokerList.Count() + " handlers");
            foreach (var invoker in handlerInvokerList)
            {
                invoker.Invoke(@event as IDomainEvent);
            }
            _logger.Debug("[evt dispatcher] dispatching event " + @event.ToString() + " done");
            _logger.RemoveOpType();
            //var eventHandlerType = typeof(IDomainEventHandler<>).MakeGenericType(eventType);
            
            //var handlers = _domainEventHandlerFactory.CreateHandlers(eventHandlerType);
            //if (handlers != null)
            //{
            //    foreach (var handler in handlers)
            //    {
            //        var handlerType = handler.GetType();
            //        MethodInfo mi = handlerType.GetMethod("Handle", new[] { eventType });
            //        mi.Invoke(handler, new[] { @event });
            //    }

            //    _domainEventHandlerFactory.ReleaseHandlers(handlers);
            //}
        }
开发者ID:AGiorgetti,项目名称:Prxm.Cqrs,代码行数:30,代码来源:DefaultDomainEventRouter.cs

示例6: SQLWhere_DateFormat

 public static void SQLWhere_DateFormat(ref ArrayList ParameterList, DbType type, string FieldName, Object FieldValue, string Operator, string AndOr, string StringProvider)
 {
     if (FieldValue.ToString().Trim() == "" || FieldValue.ToString().Trim() == "%%" || type != DbType.DateTime) return;
     ParameterItem pi = new ParameterItem();
     pi.ParaName = ((FieldName.ToUpper() == "ROWNUM") ? "ROWNUM_1" : CheckParaName(ParameterList, FieldName));
     switch (type)
     {
         case DbType.String:
             pi.WhereString = string.Format(" {0} TO_CHAR({1},'{4}') {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StringProvider);
             break;
         case DbType.Decimal:
             pi.WhereString = string.Format(" {0} TO_CHAR({1},'{4}') {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StringProvider);
             break;
         case DbType.VarNumeric:
             pi.WhereString = string.Format(" {0} TO_CHAR({1},'{4}') {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StringProvider);
             break;
         case DbType.DateTime:
             pi.WhereString = string.Format(" {0} TO_CHAR({1},'{4}') {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StringProvider);
             break;
     }
     pi.FieldName = FieldName;
     pi.FieldType = DbType.String;
     pi.FieldValue = FieldValue;
     ParameterList.Add(pi);
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:25,代码来源:SQLHelper.cs

示例7: SQLWhere_SubStr

 public static void SQLWhere_SubStr(ref ArrayList ParameterList, DbType type, string FieldName, Object FieldValue, string Operator, string AndOr, int StartPos, int EndPos)
 {
     if (FieldValue.ToString().Trim() == "" || FieldValue.ToString().Trim() == "%%") return;
     ParameterItem pi = new ParameterItem();
     pi.ParaName = CheckParaName(ParameterList, FieldName);
     switch (type)
     {
         case DbType.String:
             pi.WhereString = string.Format(" {0} Substr({1},{4},{5}) {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StartPos.ToString(), EndPos.ToString());
             break;
         case DbType.Decimal:
             pi.WhereString = string.Format(" {0} Substr({1},{4},{5}) {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StartPos.ToString(), EndPos.ToString());
             break;
         case DbType.VarNumeric:
             pi.WhereString = string.Format(" {0} Substr({1},{4},{5}) {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StartPos.ToString(), EndPos.ToString());
             break;
         case DbType.DateTime:
             pi.WhereString = string.Format(" {0} Substr({1},{4},{5}) {2} :{3}", AndOr, FieldName, Operator, pi.ParaName, StartPos.ToString(), EndPos.ToString());
             FieldValue = string.Format("#{0}#", FieldValue.ToString());
             break;
     }
     pi.FieldName = FieldName;
     pi.FieldType = type;
     pi.FieldValue = FieldValue;
     ParameterList.Add(pi);
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:26,代码来源:SQLHelper.cs

示例8: Convert

        public static String Convert( Object obj, Boolean isBreakline, Boolean allowNotSave ) {

            if (obj == null) return empty();

            Type t = obj.GetType();
            if (t.IsArray) return ConvertArray( obj, allowNotSave );
            if (rft.IsInterface( t, typeof( IList ) )) return ConvertList( (IList)obj, allowNotSave );
            if (rft.IsInterface( t, typeof( IDictionary ) )) return ConvertDictionary( (IDictionary)obj, isBreakline, allowNotSave );

            if (t == typeof( int ) ||
                t == typeof( long ) ||
                t == typeof( decimal ) ||
                t == typeof( double )) {
                return obj.ToString();
            }

            if (t == typeof( Boolean )) return obj.ToString().ToLower();
            if (t == typeof( DateTime ) || t == typeof( long )) return "\"" + obj.ToString() + "\"";
            if (t == typeof( String )) {
                // 转义双引号,消除换行
                return "\"" + ClearNewLine( obj.ToString() ) + "\"";
            }

            return ConvertObject( obj, isBreakline, true, allowNotSave );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:25,代码来源:JsonString.cs

示例9: CInt32

 public static Int32 CInt32(Object xobjObject)
 {
     Int32 result;
     if (xobjObject == null || !Int32.TryParse(xobjObject.ToString(), out result) || xobjObject == DBNull.Value || xobjObject.ToString() == "")
         return 0;
     else return Convert.ToInt32(xobjObject);
 }
开发者ID:FunesLisseth,项目名称:ProyectoSD,代码行数:7,代码来源:Validator.cs

示例10: CDate

 public static DateTime CDate(Object xobjObject)
 {
     DateTime result;
     if (xobjObject == null || !DateTime.TryParse(xobjObject.ToString(), out result) || xobjObject == DBNull.Value || xobjObject.ToString() == "")
         throw new Exception("Fecha invalida");
     else return Convert.ToDateTime(xobjObject);
 }
开发者ID:FunesLisseth,项目名称:ProyectoSD,代码行数:7,代码来源:Validator.cs

示例11: CInt64

 public static Int64 CInt64(Object xobjObject)
 {
     Int64 result;
     if (xobjObject == null || !Int64.TryParse(xobjObject.ToString(), out result) || xobjObject == DBNull.Value || xobjObject.ToString() == "")
         return 0;
     else return (Int64)xobjObject;
 }
开发者ID:FunesLisseth,项目名称:ProyectoSD,代码行数:7,代码来源:Validator.cs

示例12: LoadState

        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            var itemId = navigationParameter.ToString();
            var item = DataSource.Instance.GetItem(navigationParameter.ToString());
            this.DefaultViewModel["Item"] = item;
            this.DefaultViewModel["ItemElements"] = item.Elements;

            var serviceItem = DataSource.Instance.GetItem(itemId.Split('/').First());
            var odataClient = new ODataClient(serviceItem.Subtitle);
            var results = (odataClient.FindEntries(itemId.Split('/').Last()).Take(10));

            foreach (var key in results.First().Keys)
            {
                this.gridResult.ColumnDefinitions.Add(new ColumnDefinition());
            }
            for (int index = 0; index < results.Count(); index++)
            {
                this.gridResult.RowDefinitions.Add(new RowDefinition());
            }
            this.DefaultViewModel["QueryResults"] = results.Select(x => x.Values.ToArray());
        }
开发者ID:object,项目名称:ODataPad,代码行数:36,代码来源:ResultPage.xaml.cs

示例13: GetUserTotalMessagesSent

        public int GetUserTotalMessagesSent(Object datingBookId)
        {
            var dataBase = _serverWrapper.ServerConnection.GetDatabase("gokapara-newyork");
            var collection = dataBase.GetCollection(MESSAGE_SESSIONS_COLLECTION_NAME);

            var match1 = BsonDocument.Parse(@"{""$match"" : { $or : [
                                                                        { ""user_1"" : ObjectId(""" +datingBookId.ToString()[email protected]""")},
                                                                        {""user_2"" : ObjectId(""" + datingBookId.ToString() [email protected]""")}
                                                                    ]
                                                            }
                                               }");
            var project = BsonDocument.Parse(@"{""$project"" : { ""messages"" : ""$messages"" }}");
            var unwind = BsonDocument.Parse(@"{""$unwind"" :""$messages""}");
            var match2 = BsonDocument.Parse(@"{""$match"" : {""messages.from"" : ObjectId("""+ datingBookId + @""")}}");
            var group = BsonDocument.Parse(@"{""$group"" :  {
                                                                ""_id"" : ""$messages.from"",
                                                                ""count"" : { ""$sum"" : 1}
                                                            }
                                             }");

            var result = collection.Aggregate(match1, project, unwind, match2, group);
            if (result.Ok)
            {
                var res = result.ResultDocuments.FirstOrDefault();
                if(res != null)
                {
                    return res["count"].AsInt32;
                }
            }
            return 0;
        }
开发者ID:xoperator,项目名称:GoKapara,代码行数:31,代码来源:ActivityDataProvider.cs

示例14: toBoolean

        /**
         * using the original implementation
         * added check for empty lists
         * defaulting to "true"
         */
        public bool toBoolean(Object val)
        {
            if (val == null)
            {
                //controlNullOperand();
                return false;
            }
            else if (val is Boolean)
            {
                return ((Boolean) val);
            }
            else if (val is int)
            {
                double number = Double.Parse(val.ToString());
                return !Double.IsNaN(number) && Math.Abs(number) > 0.000000000001;
            }
            else if (val is String)
            {
                String strval = val.ToString();
                return strval.Length > 0 && !"false".Equals(strval);
            }
            else if (val is ICollection)
            {
                return (val as ICollection).Count > 0;
            }

            return true;
        }
开发者ID:rnrn,项目名称:Jade4Net,代码行数:33,代码来源:JadeJexlArithmetic.cs

示例15: CDbl

 public static double CDbl(Object xobjObject)
 {
     double result;
     if (xobjObject == null || !double.TryParse(xobjObject.ToString(), out result) || xobjObject == DBNull.Value || xobjObject.ToString() == "")
         return 0;
     else return Convert.ToDouble(xobjObject);
 }
开发者ID:FunesLisseth,项目名称:ProyectoSD,代码行数:7,代码来源:Validator.cs


注:本文中的System.Object.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。