Error CS0117: 'System.Type' does not contain a definition for 'GetTypeCode'

巧了我就是萌 提交于 2019-12-30 23:14:09

问题


Can someone please help me learn how to read and navigate the msdn docs?

Is this not supported in .net 4.0+ ?

using System;

...

public static bool IsPositive( object Value, bool ZeroIsPositive )
{
    switch ( Type.GetTypeCode( Value.GetType() ) )
    {
        case TypeCode.SByte:

I'm finding it very difficult to find my way through the docs and know what applies to Windows Store Apps specifically...


回答1:


Type.GetTypeCode() is supported in full .NET apps and non-Store portable class libraries, but not in Windows Store apps.

If you look at the Type class documentation in .NET 4.5, you can see a green shopping bag next to all of the members which are supported in Windows Store apps.

You can also look at the bottom of the page for each individual member. For example, Type.GetArrayRank has this:

Version Information
.NET Framework
Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client Profile
Supported in: 4, 3.5 SP1
Portable Class Library
Supported in: Portable Class Library
.NET for Windows Store apps
Supported in: Windows 8

... whereas Type.GetTypeCode has:

Version Information
.NET Framework
Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client Profile
Supported in: 4, 3.5 SP1
Portable Class Library
Supported in: Portable Class Library

(Note the lack of a mention of Windows Store.)



来源:https://stackoverflow.com/questions/13468864/error-cs0117-system-type-does-not-contain-a-definition-for-gettypecode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!