Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding reference in C#
Message
 
À
04/09/2010 05:00:49
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Divers
Thread ID:
01480125
Message ID:
01480127
Vues:
66
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform