hello,
i tried an example of type initializer (static constructors), and when i looked up the IL code, it used some attributes like HidbySig, specialname, rtspecialname and named it as .cctor.
what do these 4 things imply??
thank you.
Printable View
hello,
i tried an example of type initializer (static constructors), and when i looked up the IL code, it used some attributes like HidbySig, specialname, rtspecialname and named it as .cctor.
what do these 4 things imply??
thank you.
hmmm. I don't think i've ever tried to understand any IL, but if your interested in it, they have some books on amazon.com.
.cctor is short for "Constructor".
IL is an advanced topic. You are wasting your time looking at it if you don't understand C# first.
i know C#, there were few things like Un/Boxing which could be understand using IL. I am not much into IL thing, this time I used a static constructor so did it out of curiosity.
BTW, Constructor is .ctor!! .cctor is Static Constructor. just tried this code to confirm
as for HidBySig, got this:Code:using System;
using System.Reflection;
class Test
{
static Test() { }
public Test(int i) { }
public Test(string s) { }
}
class Demo
{
static void Main()
{
Type[] paramtypes = new Type[0];
ConstructorInfo ctor = typeof(Test).GetConstructor(
BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
CallingConventions.Standard, paramtypes, null);
ConstructorInfo[] c = typeof(Test).GetConstructors(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Console.WriteLine("ctortype: Attribs\n");
foreach (ConstructorInfo c1 in c)
{
Console.WriteLine("{0}\t: {1}", c1.Name, c1.Attributes);
}
Console.ReadLine();
}
}
though i could not get the exact picture of its necessity.Quote:
'hidebysig' attribute only hides base class methods with the same name if they also have the same sigature (return type and parameter types).
:eek:
:bump:
:cry: