Thread: C# Having a class have a default return value

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    62

    C# Having a class have a default return value

    Hey all.
    I'm wondering if it's possible to have a class return a field of it's by default when it's used on the right hand side.

    for example:
    Code:
    namespace NAME_SPACE
    {
        class MyClass
        {
            public int MyInt;
            public int MyClass //I'm guessing something like this?
            {
                get
                {
                    return MyInt;
                }
                set
                {
                    MyInt = value;
                }
            }
            static Main(string [] args)
            {
                int foo = MyClass; //NOTE THIS HERE
            }
        }
    Last edited by Shingetsu Kurai; 12-05-2011 at 11:11 PM. Reason: Intendations to code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class read as variable, default-type int? Say what?!
    By arcaine01 in forum C++ Programming
    Replies: 8
    Last Post: 07-10-2009, 05:34 PM
  2. Default class template problem
    By Elysia in forum C++ Programming
    Replies: 5
    Last Post: 07-11-2008, 08:44 AM
  3. Default Class Operators
    By symbiote3 in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2008, 01:44 PM
  4. How to set a "default" return value for a class?
    By Dash_Riprock in forum C++ Programming
    Replies: 3
    Last Post: 11-20-2006, 07:05 PM
  5. Default Message Handler in a Class
    By Epo in forum Windows Programming
    Replies: 2
    Last Post: 07-23-2005, 09:28 PM

Tags for this Thread