Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding reference in C#
Message
 
To
04/09/2010 05:00:49
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Miscellaneous
Thread ID:
01480125
Message ID:
01480127
Views:
65
This message has been marked as the solution to the initial question of the thread.
>Hi,
>I found a code snippet and have questions about it:
>1. when I try to run it gives me "the 'MyClasss' does not exist in the current context" error.
>2. why can "s" be referenced in line "MyClassp = s;" as "s" and what is passed by it to MyClassp?
>thanks
>
>
>
>using System;
>using System.Collections.Generic;
>using System.Text;
>
>    class MyClass
>    {
>        public int x;
>    }
>
>    class Program
>    {
>        static public void Main()
>        {
>            MyClasss = new MyClass();
>            s.x = 10;
>
>            MyClassp = s;
>            p.x = 14;
>
>            Console.WriteLine(s.x);
>            Console.ReadLine();
>        }
>    } 
>
MyClasss = new MyClass();

this should be MyClass s = new MyClass();

and  MyClassp = s;
should be  MyClass p = s;
hope that helps
Regards,
Peter J. Kane



Pete
Previous
Reply
Map
View

Click here to load this message in the networking platform