all groups > vj# > march 2004 >
You're in the

vj#

group:

GetConstructors() function


GetConstructors() function Reshma
3/24/2004 9:46:06 PM
vj#:
hello
Can any one please tell me the order in which GetConstructors(BindingFlags) function returns the constructors? This is because in C# the function takes the constructors in the order in which they are defined but in J# it always takes static construtors at last

This resulted in change in output of J# as compared to C#

The actual code is

// <Snippet2
import System .*
import System.Reflection .*

public class


public t()

} //

stati

} //

public t(int i

} //

public static void main(String[] args

ConstructorInfo p[] = t .class.ToType().GetConstructors
(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPubli
| BindingFlags.Instance))
Console.WriteLine(p.length)

for(int i=0;i< p.length;i++)
Console.WriteLine(p[i].get_IsStatic())
}
} //mai
} //
// </Snippet2


Thanks
RE: GetConstructors() function mikegreonline NO[at]SPAM microsoft.com
3/29/2004 7:29:06 PM
The same code gets executed when you call Type.GetConstructors() regardless
of which language you call it with, since the Type class is implemented in
C#. The difference you are seeing is probably related to the difference in
how the J# compiler stores information about classes. It is not a good
idea to make any assumptions in code about the order in which the
constructors will be returned as it might be changed in later versions of
the .Net framework.

I hope this is helpful,

Michael Green
Microsoft Developer Support

--------------------
| Thread-Topic: GetConstructors() function
| thread-index: AcQSLHddgo8rx00VQtyFOMQiR7yixg==
| X-Tomcat-NG: microsoft.public.dotnet.vjsharp
| From: =?Utf-8?B?UmVzaG1h?= <anonymous@discussions.microsoft.com>
| Subject: GetConstructors() function
| Date: Wed, 24 Mar 2004 21:46:06 -0800
| Lines: 44
| Message-ID: <C6F610D9-780C-40CA-9F9E-75F75BB9AD93@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.vjsharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.vjsharp:5734
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.dotnet.vjsharp
|
| hello,
Can any one please tell me the order in which
GetConstructors(BindingFlags) function returns the constructors? This is
because in C# the function takes the constructors in the order in which
they are defined but in J# it always takes static construtors at last.

This resulted in change in output of J# as compared to C#.

The actual code is.

// <Snippet2>
import System .* ;
import System.Reflection .* ;


public class t
{

public t()
{
} //t

static
{
} //t

public t(int i)
{
} //t

public static void main(String[] args)
{
ConstructorInfo p[] = t .class.ToType().GetConstructors(
(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic
| BindingFlags.Instance));
Console.WriteLine(p.length);

for(int i=0;i< p.length;i++){
Console.WriteLine(p[i].get_IsStatic());
}
} //main
} //t
// </Snippet2>


Thanks.

|
AddThis Social Bookmark Button