RIG000
پنج شنبه 24 مهر 1393, 08:58 صبح
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
public class Person
{
// سازنده همیشه وجود دارد به طور مخفی اما ما باید بنویسیمش
public Person()
{
this.Name = "Amin";
this.Family = "Saadati";
}
// این یک فیلد است
private string _name;
private string _family;
// این یکپروپرتی است
public string Name { get { return _name; } set { value= _name; } }
public string Family { get { return _family; } set { value = _family; } }
//این یک پرورتی readonly است
public string ShowInfo { get { return String.Format("{0}{1}",this.Name,this.Family); } }
}
}
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Person person_1 = new Person();
Console.WriteLine("{0}",person_1.ShowInfo);
Console.ReadKey();
}
}
}
warning داره .!!
null میکنه مقدار رو.....
Warning 1 Field 'ConsoleApplication1.Person._name' is never assigned to, and will always have its default value null D:\Projeha khob\Csharp Introduction\Chapter 01\ConsoleApplication1\ConsoleApplication1\Person. cs 19 24 ConsoleApplication1
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
public class Person
{
// سازنده همیشه وجود دارد به طور مخفی اما ما باید بنویسیمش
public Person()
{
this.Name = "Amin";
this.Family = "Saadati";
}
// این یک فیلد است
private string _name;
private string _family;
// این یکپروپرتی است
public string Name { get { return _name; } set { value= _name; } }
public string Family { get { return _family; } set { value = _family; } }
//این یک پرورتی readonly است
public string ShowInfo { get { return String.Format("{0}{1}",this.Name,this.Family); } }
}
}
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Person person_1 = new Person();
Console.WriteLine("{0}",person_1.ShowInfo);
Console.ReadKey();
}
}
}
warning داره .!!
null میکنه مقدار رو.....
Warning 1 Field 'ConsoleApplication1.Person._name' is never assigned to, and will always have its default value null D:\Projeha khob\Csharp Introduction\Chapter 01\ConsoleApplication1\ConsoleApplication1\Person. cs 19 24 ConsoleApplication1