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


C# Type.ToString方法代码示例

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


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

示例1: VerifyInvalidReadValue

        private bool VerifyInvalidReadValue(int iBufferSize, int iIndex, int iCount, Type exceptionType)
        {
            bool bPassed = false;
            Char[] buffer = new Char[iBufferSize];

            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_NAME);
            DataReader.Read();
            if (!DataReader.CanReadValueChunk)
            {
                try
                {
                    DataReader.ReadValueChunk(buffer, 0, 5);
                    return bPassed;
                }
                catch (NotSupportedException)
                {
                    return true;
                }
            }
            try
            {
                DataReader.ReadValueChunk(buffer, iIndex, iCount);
            }
            catch (Exception e)
            {
                CError.WriteLine("Actual   exception:{0}", e.GetType().ToString());
                CError.WriteLine("Expected exception:{0}", exceptionType.ToString());
                bPassed = (e.GetType().ToString() == exceptionType.ToString());
            }

            return bPassed;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:33,代码来源:ReadValue.cs

示例2: ReadContentAsAsync

        // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, 
        // and converts the content to the requested type. Stops at start tags and end tags.
        public virtual async Task<object> ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
        {
            if (!CanReadContentAs())
            {
                throw CreateReadContentAsException("ReadContentAs");
            }

            string strContentValue = await InternalReadContentAsStringAsync().ConfigureAwait(false);
            if (returnType == typeof(string))
            {
                return strContentValue;
            }
            else
            {
                try
                {
                    return XmlUntypedStringConverter.Instance.FromString(strContentValue, returnType, (namespaceResolver == null ? this as IXmlNamespaceResolver : namespaceResolver));
                }
                catch (FormatException e)
                {
                    throw new XmlException(SR.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
                }
                catch (InvalidCastException e)
                {
                    throw new XmlException(SR.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
                }
            }
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:30,代码来源:XmlReaderAsync.cs

示例3: IsTypeDefaulted

    public bool IsTypeDefaulted(Type type)
    {
        string typeName = type.ToString();

        bool isDefaulted = false;

        if (cachedTypesDefaultYes.Contains(typeName))
        {
            isDefaulted = true;
        }
        else if (cachedTypesDefaultNo.Contains(typeName))
        {
            isDefaulted = false;
        }
        else
        {
            List<string> classNames = GetClassNames(type);
            isDefaulted = classNames.Intersect(typesToDefault).Count() > 0;

            if (isDefaulted)
            {
                cachedTypesDefaultYes.Add(typeName);
            }
            else
            {
                cachedTypesDefaultNo.Add(typeName);
            }
        }

        return isDefaulted;
    }
开发者ID:AndreiMarks,项目名称:ghost-bird,代码行数:31,代码来源:PPDefaults.cs

示例4: StringEnum

		/// <summary>
		/// Creates a new <see cref="StringEnum"/> instance.
		/// </summary>
		/// <param name="enumType">Enum type.</param>
		public StringEnum(Type enumType)
		{
			if (!enumType.IsEnum)
				throw new ArgumentException(String.Format("Supplied type must be an Enum.  Type was {0}", enumType.ToString()));

			_enumType = enumType;
		}
开发者ID:wshanshan,项目名称:DDD,代码行数:11,代码来源:StringEnum.cs

示例5: Analyze

 void Analyze( Type targettype )
 {
     Console.WriteLine( "analyzing " + targettype.ToString() + " ... " );
     foreach( MemberInfo memberinfo in targettype.GetMembers() )
     {
         //Console.WriteLine( memberinfo.MemberType.ToString() + " " + memberinfo.Name );
         if( memberinfo.MemberType == MemberTypes.Field )
         {
             //Console.WriteLine( memberinfo.Name );
             FieldInfo fi = targettype.GetField( memberinfo.Name );
             Console.WriteLine( "Field: " + memberinfo.Name + " " + fi.FieldType + " isliteral " + fi.IsLiteral.ToString() );
         }
         else if( memberinfo.MemberType == MemberTypes.Property )
         {
             //Console.WriteLine( memberinfo.Name );
             PropertyInfo pi = targettype.GetProperty( memberinfo.Name );
             Console.WriteLine( "Property: " + pi.PropertyType + " " + memberinfo.Name );
         }
         else if( memberinfo.MemberType == MemberTypes.Method )
         {
             Console.WriteLine( memberinfo.MemberType.ToString() + " " + memberinfo.Name );
             MethodBase methodbase = memberinfo as MethodBase;
             MethodInfo methodinfo = memberinfo as MethodInfo;
             Console.WriteLine( "   returntype " + methodinfo.ReturnType.ToString() );
             ParameterInfo[] parameterinfos = methodbase.GetParameters();
             for( int i = 0; i < parameterinfos.GetUpperBound(0) + 1; i ++ )
             {
                 Console.WriteLine( "   parameter " + parameterinfos[i].ParameterType + " " + parameterinfos[i].Name );
             }
             //Console.WriteLine( memberinfo.Name );
             //MethodInfo mi = targettype.GetMethod( memberinfo.Name );
             //Console.WriteLine( memberinfo.Name );
         }
     }
 }
开发者ID:achoum,项目名称:spring,代码行数:35,代码来源:AbicWrapperGenerator.cs

示例6: GooBinaryPointer

    public GooBinaryPointer(GooBinaryRange range, Type dataType)
    {
        int typeSize = 1;

        if (dataType == typeof(byte)) {
            typeSize = 1;
            _typeString = "uint8";
        }
        else if (dataType == typeof(ushort)) {
            typeSize = 2;
            _typeString = "uint16";
        }
        else if (dataType == typeof(uint)) {
            typeSize = 4;
            _typeString = "uint32";
        }
        else if (dataType == typeof(float)) {
            typeSize = 4;
            _typeString = "float32";
        }
        else {
            throw new ArgumentException("Unrecognized range type " + dataType.ToString());
        }

        if (range.Length % typeSize != 0) {
            throw new ArgumentException("Mesh data is not even multiple of element size");
        }

        _start = range.Start;
        _length = range.Length / typeSize;
    }
开发者ID:GooTechnologies,项目名称:CreateUnityExporter,代码行数:31,代码来源:GooBinaryPointer.cs

示例7: Array

 public Array(Type type) {
     base.SetType(new Type(type, true));
     gszItemType = type.ToString();
     gItems = new List<Object>();
     //base.SetType("Array");
     //gszItemType = szType;
 }
开发者ID:inmount,项目名称:dyk.dll,代码行数:7,代码来源:Array.cs

示例8: LoadConfig

	public static Dictionary<int, BaseConfig> LoadConfig(string path, Type type)
	{
		int jsonStartIndex = 4;
		int columnStartIndex = 1;

		var ta = Resources.Load(path) as TextAsset;
		string RawJson = ta.text;

		Dictionary<int, BaseConfig> dic = new Dictionary<int, BaseConfig>();
		TabFileReader tabReader = new TabFileReader();
		tabReader.Load(RawJson);
		int JsonNodeCount = tabReader.RowCount;
		for (int i = jsonStartIndex; i < JsonNodeCount; i++)
		{
			try
			{
				System.Reflection.ConstructorInfo conInfo = type.GetConstructor(Type.EmptyTypes);
				BaseConfig t = conInfo.Invoke(null) as BaseConfig;

				t.init(tabReader, i, columnStartIndex);
				if (0 != t.id)
				{
					if (!dic.ContainsKey(t.id))
						dic.Add(t.id, t);
					else
						Log.LogError("Config Data Ready Exist, TableName: " + t.GetType().Name + " ID:" + t.id);
				}
			}
			catch (Exception)
			{
				Log.LogError(type.ToString() + " ERROR!!! line " + (i + 2).ToString());
			}
		}
		return dic;
	}
开发者ID:HawardLocke,项目名称:MadLand,代码行数:35,代码来源:ConfigLoader.cs

示例9: AddField

		public static void AddField (StringBuilder sb, int n, Type val)
		{
			if (val != null) {
				sb.Append (n.ToString(CultureInfo.InvariantCulture));
				sb.Append (val.ToString());
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:KeyHelper.cs

示例10: SetPurchaseType

 public void SetPurchaseType(Button button,Type type)
 {
     PurchaseImage = Array.Find(FindObjectsOfType<JuiceType>(), i => i.name == type.ToString()).GetComponent<Image>();
     PurchaseType = type;
     AllButtonDisable();
     button.image.sprite = onPushButtonSprite;
     SceneManager.Instance.StartChange(SceneNameManager.Scene.Purchase, new FadeTimeData(1, 1));
 }
开发者ID:syougun-ugp,项目名称:Juice_De_Pon,代码行数:8,代码来源:PurchaseManager.cs

示例11: DeriveParametersNotSupported

 internal static InvalidOperationException DeriveParametersNotSupported(Type type, CommandType commandType)
 {
     var args = new[] {type.ToString(), commandType.ToString()};
     return
         new InvalidOperationException(
             GetExceptionMessage(
                 "{0} DeriveParameters only supports CommandType.StoredProcedure, not CommandType.{1}.", args));
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:8,代码来源:ExceptionHelper.cs

示例12: EditableEntity

 public EditableEntity(Type sqlClientEntityType)
 {
     this.m_sqlClientEntity = Activator.CreateInstance(sqlClientEntityType) as MyGeneration.dOOdads.SqlClientEntity;
     if (this.m_sqlClientEntity == null)
     {
         throw new Exception("Can't create SqlClientEntity of type " + sqlClientEntityType.ToString());
     }
 }
开发者ID:ivladyka,项目名称:Ekran,代码行数:8,代码来源:EditableEntity.cs

示例13: GetPieceParent

 public static GameObject GetPieceParent(Type piece)
 {
     if (!RoomManager.pieceParents.ContainsKey(piece) || RoomManager.pieceParents[piece] == null)
     {
         GameObject preexisting = GameObject.Find(piece.ToString().UppercaseFirst() + " Group");
         if (preexisting != null && preexisting.transform.parent == RoomManager.masterParent.transform)
         {
             RoomManager.pieceParents[piece] = preexisting;
         }
         else
         {
             RoomManager.pieceParents[piece] = new GameObject();
             RoomManager.pieceParents[piece].name = piece.ToString().UppercaseFirst() + " Group";
             RoomManager.pieceParents[piece].transform.parent = RoomManager.masterParent.transform;
         }
     }
     return RoomManager.pieceParents[piece];
 }
开发者ID:GameMakersUnion,项目名称:CubeRollersDeluxe,代码行数:18,代码来源:PuzzleMaker.cs

示例14: EnableBehaviour

    protected void EnableBehaviour( Type componentType ) {
        Behaviour behaviour = GetComponentInChildren( componentType, true ) as Behaviour;

        if (behaviour == null) {
            Debug.Log( componentType.ToString( ) + " not present on player" );
        } else {
            behaviour.enabled = true;
        }
    }
开发者ID:dirty-casuals,项目名称:Calamity,代码行数:9,代码来源:ComponentEnabler.cs

示例15: GetTypeStr

    public string libName = "";         //注册到lua的名字

    string GetTypeStr(Type t) {
        string str = t.ToString();

        if (t.IsGenericType) {
            str = GetGenericName(t);
        } else if (str.Contains("+")) {
            str = str.Replace('+', '.');
        }

        return str;
    }
开发者ID:orlandooyq,项目名称:uLua,代码行数:13,代码来源:BindLua.cs


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