What is Classes in C#? Objects Access Modifiers https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers https://www.cnblogs.com/xinaixia/p/5775471.html Code using System; //class declaration public class Car { //instance 6 variables String name; String color; String transmission; String bodytype; int seat; int year; //constructor declaration of class public Car(String name, String color, String transmission, String bodytype, int seat, int year) { this.name = name; this.color = color; this.transmission = transmission; this.bodytype = bodytype; this.seat = seat; this.year = year; } //property 6 public String getName() { return name; } public String getColor() { return color; } public String getTransmission() { return transmission; } public String getType() { return bodytype; } public int getSeat() { return seat; } public int getYear() { return year; } //method public String ToString() { return ("This is Car detail- CarName:" + this.getName() + "\n Color :" + this.getColor() + "\n Transmission: " + this.getTransmission() + "\n Body type: " + this.getType() + "\n Seat : " + this.getSeat() + "\n Year: " + this.getYear())+"\n ================="; } //main method public static void Main(string[] args) { // 5 object Car Toyota = new Car("Toyota Rush", "Silver", "Auto", "SUV", 7, 2020); Car Bmw = new Car("BMX X1", "Silver", "Auto", "SUV", 7, 2022); Car Honda = new Car("Accord", "Black", "Auto", "Sedan", 4, 2016); Car Tesla = new Car("Tesla S", "Red", "Auto", "Sedan", 4, 2017); Car Mazda = new Car("Mazda 929 Legato", "White", "Manual", "Sedan", 4, 1980); //output Console.WriteLine(Toyota.ToString()); Console.WriteLine(Bmw.ToString()); Console.WriteLine(Honda.ToString()); Console.WriteLine(Tesla.ToString()); Console.WriteLine(Mazda.ToString()); Console.WriteLine("==============\n Thank you !"); //out put date and time DateTime now = DateTime.Now; Console.WriteLine("Print date: " + now); Console.ReadLine(); } }

October 20, 2022 0comments 38hotness 0likes Read all

IDEA User input data Convert to index Using index number fund element vaule Output element vaule Screenshot Code using System; namespace array2d { public class array2d { public static void Main(string[] args) { //initilizing arrays string[,] platenumber = new string[5,3] { {"ZJI163","USA1008","PHA101"}, {"PJ130108", "USA1006","JAP118" }, {"MAX168", "USA1002" ,"TWD120"}, { "AZZ9756", "USA1005","KOR119" }, {"NAS1223","USA109","DDT886"} }; //wait for user input,convert to int Console.WriteLine("Welcome use DK parking system!\n Solt: 0-4 \n floor: 0-2"); Console.WriteLine("Plz type slot: "); int solt = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Plz type floor: "); int floor = Convert.ToInt32(Console.ReadLine()); // decision the length of the element if (solt < 5 && floor < 3) { string car = platenumber[solt, floor]; Console.WriteLine("Found platenumber is :" + car); } else { Console.WriteLine("\nThe value you entered does not exist"); } Console.WriteLine("Thank you !"); Console.ReadLine(); } } }

October 16, 2022 0comments 35hotness 0likes Read all

C# Multidimensional Arrays As discussed in the previous chapter, Arrays in C# will support multi-dimensional arrays. In c#, a multidimensional array is an array that contains more than one dimension to represent the elements in a tabular format like rows and columns.In c#, multidimensional arrays can support either two or three-dimensional series. To create multi-dimensional arrays, we need to use a comma (,) separator inside the square brackets. C# Multi-Dimensional Array Declaration In c#, Multidimensional Arrays can be declared by specifying the data type of elements followed by the square brackets [] with comma (,) separator. The following are examples of creating two or three-dimensional arrays in the c# programming language. Question: Create a complete C# program that will compute the average of all elements in array x int [,] x = new int[4, 5] { { 4, 5, 6, 2, 12 }, { 10, 25, 33, 22, 11 },{ 211, 32, 43, 54, 65 }, { 3, 2, 1, 5, 6 } }; Average Solution Use for loop get array x elements values Add values Divide results by no. of values Code using System; namespace Module7 { public class Module7 { public static void Main(string[] args) { //initilizing array int[,] x = new int[4, 5] { { 4, 5, 6, 2, 12 }, { 10, 25, 33, 22, 11 }, { 211, 32, 43, 54, 65 }, { 3, 2, 1, 5, 6 } }; Console.WriteLine("---Two dimensional array elements---"); // use for loop get array x elements for(int y=0; y<4; y++) { int sum = 0; double avg =…

October 4, 2022 0comments 36hotness 0likes Read all

Question: Create a complete C# program that will simulate a log-in process. If the username and password are both correct the program will display “Log-in Successful”, otherwise it will display “Invalid Log-in details” FlowChart: C# Logical Operators: Code Answer: using System; namespace Module6 { class module6 { static void Main(string[] args) { string emailid, password; //use readline get user input Console.WriteLine("Plz enter u Emaill address :"); emailid = Console.ReadLine(); Console.WriteLine("Plz enter u Password"); password = Console.ReadLine(); //use if else to decision input data contains value if (emailid.Contains("[email protected]") && (password.Contains("d123456"))) { Console.WriteLine("Your Log-in Was Successful!"); } else { Console.WriteLine("Invalid Log-in details"); } Console.ReadLine(); } } } Reference C# Logical Operators with Exampleshttps://www.tutlane.com/tutorial/csharp/csharp-logical-operators-with-examples C# String Contains()https://www.javatpoint.com/csharp-string-contains

October 3, 2022 0comments 44hotness 0likes Read all