×
Aiming for the stars? Great, but did you have to build a rocket first.
--Your friends at LectureNotes
Close

Note for Dot Net Framework for Application Development - DFAD By Adarsh lakshetty

  • Dot Net Framework for Application Development - DFAD
  • Note
  • Visveswaraya Technological University - Vtu
  • Computer Science Engineering
  • 5 Topics
  • 17133 Views
  • 307 Offline Downloads
  • Uploaded 1 year ago
Adarsh Lakshetty
Adarsh Lakshetty
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-3

Dot Net Framework for Application Development CBCS V Semester Subject code :15CS564 grows as project size grow. 4) Type Safe C# type safe code can only access the memory location that it has permission to execute. Therefore it improves a security of the program. 5) Interoperability Interoperability process enables the C# programs to do almost anything that a native C++ application can do. 6) Scalable and Updateable C# is automatic scalable and updateable programming language. For updating our application we delete the old files and update them with new ones. 7) Component Oriented C# is component oriented programming language. It is the predominant software development methodology used to develop more robust and highly scalable applications. 8) Structured Programming Language C# is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify. 9) Rich Library C# provides a lot of inbuilt functions that makes the development fast. 10) Fast Speed The compilation and execution time of C# language is fast. C# Example: Welcome program In C# programming language, a simple " Welcome program " program can be written by multiple ways. Let's see the top 4 ways to create a simple C# example: Simple Example Using System Using public modifier Using namespace Prof Adarsh L , Dept of CSE BKEC, Basavakalyan Page 3

Text from page-4

Dot Net Framework for Application Development CBCS V Semester Subject code :15CS564 C# Simple Example include all 4 ways using System; namespace CSE { public class Program { public static void Main(string[] args) { .Net framework Namespace Methods Data type Class name Console.WriteLine("Welcome to CSE "); } Methods to display value on Console } } Output: Welcome to CSE department Description class: is a keyword which is used to define class. Program: is the class name. A class is a blueprint or template from which objects are created. It can have data members and methods. Here, it has only Main method. static: is a keyword which means object is not required to access static members. So it saves memory. void: is the return type of the method. It does't return any value. In such case, return statement is not required. Main: is the method name. It is the entry point for any C# program. Whenever we run the C# program, Main() method is invoked first before any other method. It represents start up of the program. string[] args: is used for command line arguments in C#. While running the C# program, we can pass values. These values are known as arguments which we can use in the program. System.Console.WriteLine("Welcome to CSE department "): Here, System is the namespace. Console is the class defined in System namespace. The WriteLine() is the static method of Console class which is used to write the text on the console. Example: Simple Console Project with C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharp Prof Adarsh L , Dept of CSE BKEC, Basavakalyan Page 4

Text from page-5

Dot Net Framework for Application Development CBCS V Semester Subject code :15CS564 { class Program { static void Main(string[] args) { string message = "Hello World!!"; Console.WriteLine(message); } } } C# Variable The variable in C# is nothing but a name given to a data value. In the above example, message is the name of the variable that stores the string data value "Hello World!!". As the name suggests, the contents of a variable can vary, i.e., you can change the value of a variable at any time. In C#, a variable is always defined with a data type. The following is the syntax variable declaration and initialization. Syntax: <data type> <variable name>; <datatype> <variable name> = <value>; A variable can be declared and initialized later or it can be declared and initialized at the same time. In the following example, the first statement declares a variable called "message" without assigning any value to it. In the second statement, a value is assigned to the "message" variable. Example: Variable declaration string message; // value can be assigned after it declared message = "Hello World!!"; Multiple variable declaration int i, j, k, l = 0; int amount, num; Variable assignment int i = 100; int j = i; // value of j will be 100 Invalid Variable Assignment Prof Adarsh L , Dept of CSE BKEC, Basavakalyan Page 5

Text from page-6

Dot Net Framework for Application Development CBCS V Semester Subject code :15CS564 string message = "Hello World!!"; int i = message; // compile time erro Rule for variable • It is a way to represent memory location through symbol so that it can be easily identified. • Rules for defining variables • A variable can have alphabets, digits and underscore. • A variable name can start with alphabet and underscore only. It can't start with digit. • No white space is allowed within variable name. • A variable name must not be any reserved word or keyword e.g. char, float etc. • variable are separeted by commas (,). • No two Succesive underscore are not allowed. Accepting Values from User The Console class in the System namespace provides a function ReadLine() for accepting input from the user and store it into a variable. For example, int num; num = Convert.ToInt32(Console.ReadLine()); The function Convert.ToInt32() converts the data entered by the user to int data type, because Console.ReadLine() accepts the data in string format. C# Data Types A data type specifies the type of data that a variable can store such as integer, floating, character Prof Adarsh L , Dept of CSE BKEC, Basavakalyan Page 6

Lecture Notes