14.02.2023 C#

Моя цель – изучить C# и поделиться своими знаниями с людьми. Я упомянул примеры с кодами комментариев.

Продолжим о C#

Сначала я поделился этой информацией в своем блоге как Python, теперь я поделюсь ею как C # в своем блоге.

bool didsheloggedin = false;   //we can image the about website log in click.
if (didsheloggedin) {
                Console.WriteLine("Settings Button"); 

            }                  //when we write our name and passaword which is correct we can see the settings  button at the screen..
            else
            {
                Console.WriteLine("lOG İN"); //if it is not correct we can see the "Log in" at the screen.
            }

double usdyesterday = 7.35;  //we assign that 7.35 to usdyesterday.its'type is double.
double usdtoday = 7.35;
if (usdyesterday>usdtoday)
   {
          Console.WriteLine("Down button shows in USD");
   }
else if (usdyesterday<usdtoday)
     {
          Console.WriteLine(" Up button shows in USD");
            }
else
            {
                Console.WriteLine("Not Changed");
            }

//bool is false that’s why it will show us the Log in button.

наши переменные: usdyesterday и usdtoday. Мы сравним их, чтобы показать нам верхнюю, нижнюю или равную отметку. Вы можете отобразить цену банка в долларах США на веб-сайте. И они одинаковы, и это покажет нам, что не меняется метка. Эта ситуация имеет 3 вероятности, поэтому мы использовали конструкторы if, else if.

Циклы

Если мы хотим иметь много временных ситуаций и считать, мы можем использовать циклы.

 for (int i = 0; i <10 ; i++)       // i++=every each loop i+1 will be.( For) is using for loop.
            {
                Console.WriteLine(i);         
            }

for (int i = 0; i <10 ; i=i+2)      //Firstly we select variable and how many times  it will work.  
            {
                Console.WriteLine(i);         //we choose it than we write the code below it.
            }
//when  you want 2,4,6,8 like that count we can write like that. 

Серия-массив

Когда у нас есть много информации, представленной многими переменными, мы используем массив. Обычно мы используем цикл. Этот метод очень прост для нас.

string course1 = "Software Developer Camp";
  string course2 = "Entry level programing for basis";
  string course3 = "Java";

До сих пор мы это знали. Мы можем обновлять их и использовать с помощью массива. И легко изменять, и читать.

string[] courses = new string[] { "Software Developer Camp" , "Entry level programing for basis", "Java" };
//we embeded which we write the inside of courses 

Notes=как мы можем увидеть массив на экране? Мы можем использовать циклы для этого.

string[] courses = new string[] { "Software Developer Camp" , "Entry level programing for basis", "Java" };
for (int i = 0; i < 2; i++)
            {
                Console.WriteLine(courses[i]); 
            }
  Console.WriteLine("Page break-footer");
//when you image the website of courses they will be listed and when it is finish page break(it is footer)

Notes=Иногда мы не знаем, сколько у него списков. Вот почему мы можем использовать метод .length.

string[] courses = new string[] { "Software Developer Camp" , "Entry level programing for basis", "Java" };

            for (int i = 0; i <courses.Length; i++)
            {
                Console.WriteLine(courses[i]);
            }
            Console.WriteLine("Page break-footer");

Notes=Это лучше, чем раньше, но мы можем обновить его до более полезного и использовать foreach.

Foreach=foreach возвращает каждую структуру на основе каждого массива. foreach возвращает проще, чем (for) в массивах.

string[] courses = new string[] { "Software Developer Camp" , "Entry level programing for basis", "Java" };
foreach (string course in courses)
            {
                Console.WriteLine(course);
            }
// course=alias we can choose something.it is up to us.

Примечания = данные не строятся только из одной информации. В реальных данных жизни строятся некоторые информации.

Класс

Класс может хранить много данных о чем-то, и мы вызываем основное программирование для использования.

//we constructed the class which is name Course.
            Course course1 = new Course();
            Course course2 = new Course();
            Course course3 = new Course();
            course1.CourseName = "C#";
            course1.Teacher = "Murat";
            course1.WathcingRate = 10;

            course2.CourseName = "Java";
            course2.Teacher = "Suat";
            course2.WathcingRate = 15;

            course3.CourseName = "Python";
            course3.Teacher = "Faruk";
            course3.WathcingRate = 30;

           Console.WriteLine(course1.CourseName + " : " + course1.Teacher);//We can see the screen about course name and teacher’s name from the class.

//we write the alise this class in the main side

//Than we write the information about course .we have 3 course like that.
        }
    }
    class Course
    {

        public string CourseName { get; set; }
        public string Teacher { get; set; }
        public int WathcingRate { get; set; }
//we constructed the class which name Course and 
//we are taking information with get operator also
 //we are adding information with set operator.
//it means every each one have different information to read and write .
    }

Console.WriteLine(course1.CourseName + " : " + course1.Teacher);

Примечания=Мы можем видеть экран каждый, но этот стиль сложен для нас. Ранее мы узнали, как мы можем писать экран с помощью массивов и псевдонимов. Вы можете увидеть ниже.

Course[] course = new Course[] {course1,course2,course3};

            foreach (var courses in course)  //course is scanned courses which is alias 
            {
                Console.WriteLine(courses.CourseName + " = " +courses.Teacher); 
            }