שאלה בקשר ל C#
לא מובן לי מדוע אני יכול לאתחל משתנה private בקוד הבא : p.x =3 מבלי שהקומפיילר צועק ?? הקוד להלן:
לא מובן לי מדוע אני יכול לאתחל משתנה private בקוד הבא : p.x =3 מבלי שהקומפיילר צועק ?? הקוד להלן:
using System; namespace rectangleGame { /// <summary> /// Summary description for Class1. /// </summary> class point { int x, y; // Default constructor: public point() { x = 0; y = 0; } // A constructor with two arguments: public point(int x, int y) { this.x = x; this.y = y; } // Override the ToString method: public override string ToString() { return(String.Format("({0},{1})", x, y)); } /// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { point p1 = new point(3,2); p1.x = 3; } } }