Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- // 3 students
- // NO OOP!
- // Student 1
- int age1 = 21;
- string name1 = "Abbas";
- // Student 2
- int age2 = 24;
- string name2 = "Kanan";
- // Student 3
- int age3 = 20;
- string name3 = "Akif";
- // 20.000 students
- // Name
- // Age
- // Type-name instance-name
- // A3 - Student
- // A3 blank page = student1
- Student student1 = new Student();
- student1.name = "Saleh";
- student1.age = 19;
- Student student2 = new Student();
- student2.name = "Taleh";
- student2.age = 33;
- // This object is not initialized
- Student student3;
- // Default values
- // integer types => 0
- // floating-point types => 0.0
- // reference types => null
- // Reference Types [string, Student] => class
- // Array - Sequence is the same type element list.
- // 78025, 1, 2, 3, 9, -44, 0, 1001, -1000, 563 - Array
- // Array Declaration Syntax:
- // type-name[] object-name = new type-name[elementOfCount];
- float[] mySequence = new float[10];
- mySequence[5] = -44.00F;
- // Float type => 4 bytes => 32 bits
- float f1 = 64.85623F;
- // Double type => 8 bytes => 64 bits
- double d1 = 64.85623;
- // All programming languages BY DEFAULT
- // Type of Integer values => int => 4 bytes => 32 bits
- // Type of Floating values => double
- // Infinity looping
- // Initialize Condition Iteration
- // 1. Initialize => int i = 0;
- // 2. Condition => i < 10
- // 3. Iteration => i++
- // Iteration: 2
- // Start value: 5
- // 5, 7, 9, 11, 13
- // Range: 0 ... 9
- // Odd indexes: 0, 2, 4, 6, 8 [+]
- // Even indexes: 1, 3, 5, 7, 9 [+]
- // increment => [i++] [i = i + 1] [i += 1]
- // decrement => [i--] [i = i - 1] [i -= 1]
- /*
- for (int i = 7; i < 17; i = i + 1)
- {
- // Concat => string join 0 + " => " ======>>>>>>> [0 => ]
- Console.Write(i - 7 + " => ");
- Console.WriteLine("{0:f1}", mySequence[i - 7]);
- }
- */
- /*
- // 7, 9, 11, 13, 15
- for (int i = 7; i < 17; i = i + 2)
- {
- // Concat => string join 0 + " => " ======>>>>>>> [0 => ]
- Console.Write(i - 7 + " => ");
- Console.WriteLine("{0:f1}", mySequence[i - 7]);
- }
- */
- /*
- // 8, 10, 12, 14, 16
- for (int i = 8; i < 17; i = i + 2)
- {
- // Concat => string join 0 + " => " ======>>>>>>> [0 => ]
- Console.Write(i - 7 + " => ");
- Console.WriteLine("{0:f1}", mySequence[i - 7]);
- }
- */
- // Array Declaration Syntax:
- // type-name[] object-name = new type-name[elementOfCount];
- Student[] students = new Student[3];
- // students.Length = 15; // ERROR!
- for (int i = 0; i < students.Length; i++)
- {
- students[i] = new Student();
- Console.Write("Name: ");
- students[i].name = Console.ReadLine();
- Console.Write("Age: ");
- students[i].age = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("All entered student list");
- for (int i = 0; i < students.Length; i++)
- {
- Console.Write("Name #" + (i + 1) + ": ");
- Console.WriteLine(students[i].name);
- Console.Write("Age #" + (i + 1) + ": ");
- Console.WriteLine(students[i].age);
- }
- }
- private class Student
- {
- // Access modifiers
- public int age;
- public string name;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement