One can manage a group of items/objects using arrays or collections, we have already talked about arrays in the previous lecture, today we will talk about collections Collections provide a more flexible way to work with a group of objects. Yes flexible, collections can grow and shrink dynamically . One of the greatest advantage over Arrays. There are many collections provided by .Net framework, we will look at the most used collection classes Generic List Strongly typed list of elements that can be accessed by using positional index number. Declaration List < string > EmpNameList ; Declared EmpNameList which will hold elements of type string Initialization EmpNameList = new List < string >(); Operations //Add Element EmpNameList . Add ( "Employee1" ); //Re...
An approach to building applications by focusing on objects that interact with one another Features of objected oriented programming 1. Flexible 2. Natural 3. Reuse of code 4. Testable In this course, we will be using C# as our object-oriented programming language. C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft Now we talk about some main topics/concepts or building blocks of object-oriented programming Classes and object Classes are the blueprint for objects Objects are an instance of a class Now that sounds like definitions, good to say during interviews 😜 Well to make more sense and to get the real essence of this definition we will do some object-oriented programming. Consider you got a new project or client r...
Namespaces You would have recognized our class is wrapped in namespace block in our earlier lectures. Namespaces are used to organize classes in separate containers, you can consider them as an address of your class that helps the compiler to find the class. They are automatically added around the class and usually has the same name as the project they belong Here we can see Class1 is inside namespace NameSpaceDemo Imagine your application has multiple Class1 classes and now how do you guide the compiler on which one to pick, namespaces helps here. You can access the class using Namespace then dot the class name. NameSpaceDemo . Class1 Below one of the built-in namespace System . Console . WriteLine( "Test Namespace" ); Here System is the Namespace The console is the Class name WriteLine is the method name Properties Properties allow you to control the accessibility of class variables. Can be also called as guard ac...
Comments
Post a Comment