Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Visual J# / March 2004

Tip: Looking for answers? Try searching our database.

GetConstructors() function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Reshma - 25 Mar 2004 06:46 GMT
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
Michael Green - 29 Mar 2004 20:29 GMT
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==
[quoted text clipped - 20 lines]
|
| 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.