Глава 3 Классы и объекты
This commit is contained in:
parent
aa050c247f
commit
2101d584f3
@ -0,0 +1,23 @@
|
|||||||
|
=== Классы и объекты ===
|
||||||
|
|
||||||
|
Person tom = new Person();
|
||||||
|
string personName = tom.name;
|
||||||
|
int personAge = tom.age;
|
||||||
|
Console.WriteLine($"name: {personName} age: {personAge}");
|
||||||
|
|
||||||
|
tom.name = "Tom";
|
||||||
|
tom.age = 37;
|
||||||
|
tom.Print();
|
||||||
|
|
||||||
|
class Person
|
||||||
|
{
|
||||||
|
public string name = "Undefined";
|
||||||
|
public int age;
|
||||||
|
|
||||||
|
public void Print()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Имя: {name} Возраст: {age}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== ===
|
||||||
@ -1,16 +1,19 @@
|
|||||||
//типы данных
|
Person tom = new Person();
|
||||||
int age = 25;
|
string personName = tom.name;
|
||||||
double price = 19.99;
|
int personAge = tom.age;
|
||||||
string name = "Vasya";
|
Console.WriteLine($"name: {personName} age: {personAge}");
|
||||||
bool active = true;
|
|
||||||
char symbol = 'S';
|
tom.name = "Tom";
|
||||||
decimal tax = 15.99M;
|
tom.age = 37;
|
||||||
DateTime today = DateTime.Now;
|
tom.Print();
|
||||||
List<string> names = new List<string> { "Vasya", "Petya" };
|
|
||||||
Dictionary<int, string> students = new Dictionary<int, string>
|
class Person
|
||||||
{
|
{
|
||||||
{1, "Alice" },
|
public string name = "Undefined";
|
||||||
{2, "Frank" },
|
public int age;
|
||||||
{3, "Ivan"}
|
|
||||||
};
|
public void Print()
|
||||||
string[] days = { "Mon", "Tue", "Wed" };
|
{
|
||||||
|
Console.WriteLine($"Имя: {name} Возраст: {age}");
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("CSHARP")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("CSHARP")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+85c2d250c01f4ee1c62a217cda019d8b45da2f44")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+aa050c247f6147a284a534e34522aed399958c7f")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("CSHARP")]
|
[assembly: System.Reflection.AssemblyProductAttribute("CSHARP")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("CSHARP")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("CSHARP")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
// Generated by the MSBuild WriteCodeFragment class.
|
// Создано классом WriteCodeFragment MSBuild.
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
3de7edf971a36d8f480ea014734f387790fab06fc009fabab9562c2e90fac240
|
8b42992521c44adabdfff2f0c94aca9302acbb4a3d22a089bd2074043d71fed8
|
||||||
|
|||||||
Binary file not shown.
@ -1 +1 @@
|
|||||||
a3bc34b74b754593ef89b2c29aac9a3ffe2f10e122c68a131fbbbdf1953586c3
|
b35e9c216da37a7db1e57c4dd5dcac470b2c3540edcd108f82c27f7703827df8
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user