This is accepted by the compiler:
FieldInfo[] fieldInfos; fieldInfos = typeof(MyClass).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
This is NOT accepted by the compiler:
FieldInfo[] fieldInfos; fieldInfos = typeof(this.GetType()).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
How to fix the second syntax?
You do not need to typeof()call around GetType, as it already returns a Type object. typeof- special syntax for getting an object Typeon behalf of a type, without having to do something like Type.GetType("Foo").
typeof()
GetType
typeof
Type
Type.GetType("Foo")
FieldInfo[] fieldInfos; fieldInfos = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
typeof System.Type. typeof - , (, Int32 object MyClass)), System.Type. , GetType, System.Type.
System.Type
Int32
object
MyClass
fieldInfos = this.GetType() .GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
typeof. :
FieldInfo[] fieldInfos = this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
typeof - "" Type. GetType() , .
GetType()
, , ... :
string x = "y.ToString()";
string x = y.ToString();
typeof(), ...
Source: https://habr.com/ru/post/1788675/More articles:Java regex - single space expression - javaVB.NET Export to Excel with non-quoted string data - .netКак предотвратить использование метода SetPixel? - c#Bind variables in mysql_query statement - phpDetecting if the router supports multicast - objective-chow to check if a domain name is available (in bulk)? - perlcon.getInputStream () throw an exception in an Android project, how to fix? - javaCannot access MySQL views when moving a PHP application to another server - mysql.gif image display using OpenGl - openglcalling pdftotext from a python script does not work when I switch from a local machine to my web hosting - pythonAll Articles