ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Enterprise Application Development
    EC-332
    Progress0 / 37 topics
    Topics
    1. Overview of Enterprise Application Development: Microsoft technology history2. Introduction to .NET and its architecture3. Concept of MSIL, CLR, CLS, CTS4. Introduction to .NET framework: Managed and Unmanaged Code5. .Net Assembly6. Introduction to C# fundamentals7. Boxing and Unboxing8. Implementing multi-tier architecture9. Introduction to ADO.Net: SQL Injection, parameterized queries10. Usage of data set, Data adapter and command builder in disconnected model11. Introduction to delegate: Multicast delegates12. Introduction to windows forms13. HTML14. Introduction to javascript: javascript and its data types, variables, functions15. Debugging javascript using Firebug16. Introduction to various object models: Browser's Object (BOM), Document Object Model17. Introduction to Jquery: Jquery effects18. Introducing LINQ: LINQ to Objects, LINQ to SQL19. Query syntax, Operations (projection, filtering and join) using Linq Queries20. Introduction to ADO.NET entity framework: The entity data model, CSDL21. Eager vs lazy loading, POCO classes, DBContext API22. Querying entity data models23. Introduction to ASP.NET MVC24. MVC application structure, Controllers overview25. Action Methods, Parameterized action methods26. Introduction to razor syntax27. Code expressions, Code Blocks, Implicit Vs Explicit Code Expression28. Data annotations, Client and Server Side Validation29. Validation and model binding, Validation and model state30. MVC Membership, Authorization and security31. Introduction to service-oriented architecture: SOAP, WSDL32. Service contract, Data contract, XML, WCF bindings33. ABC of WCF, Restful services34. Consuming rest services (CRUD operations) using Jquery AJAX and JSON35. Introduction to web API36. Example of web API using CRUD Example37. MVC routing
    EC-332›Introduction to C# fundamentals
    Enterprise Application DevelopmentTopic 6 of 37

    Introduction to C# fundamentals

    6 minread
    1,086words
    Intermediatelevel

    C# (pronounced "C-sharp") is a modern, object-oriented programming language developed by Microsoft as part of the .NET framework. It is widely used for developing a range of applications, including web, desktop, mobile, and game development. C# is a versatile and powerful language designed to be easy to learn and use, with a focus on simplicity and efficiency.

    Here’s an introduction to the fundamentals of C#:

    1. Basic Syntax

    C# is a case-sensitive language, which means that Variable and variable are treated as different identifiers. The basic structure of a C# program consists of:

    • Classes: The fundamental building blocks of C# programs.
    • Methods: Functions or procedures defined inside classes.
    • Statements: Instructions that tell the program what to do.

    Example of a simple C# program:

    using System;
    
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Hello, World!");
        }
    }
    

    In this example:

    • using System;: This includes the System namespace, which contains useful classes like Console for input/output operations.
    • class Program: Defines a class named Program.
    • static void Main(): The entry point of the C# program. When you run a C# application, this is where the program starts.
    • Console.WriteLine("Hello, World!");: Prints the string "Hello, World!" to the console.

    2. Variables and Data Types

    Variables are used to store data, and each variable must have a data type that defines the kind of data it can store. In C#, some common data types include:

    • int: For integers (whole numbers).
    • double: For floating-point numbers (decimals).
    • char: For single characters (e.g., 'a').
    • string: For text (e.g., "Hello").
    • bool: For true or false values.

    Examples of variable declarations:

    int age = 25;
    double height = 5.9;
    char grade = 'A';
    string name = "Alice";
    bool isActive = true;
    

    3. Operators

    C# supports a variety of operators, which allow you to perform operations on variables and values. These include:

    • Arithmetic Operators: +, -, *, /, %

      int sum = 10 + 5; // sum will be 15
      
    • Comparison Operators: ==, !=, >, <, >=, <=

      bool result = (10 > 5); // result will be true
      
    • Logical Operators: && (AND), || (OR), ! (NOT)

      bool result = (true && false); // result will be false
      

    4. Control Flow Statements

    Control flow statements are used to control the flow of execution in a program. C# provides several types of control flow mechanisms:

    • Conditional Statements: Used to make decisions based on conditions.

      • if, else, else if
      int age = 18;
      if (age >= 18)
      {
          Console.WriteLine("Adult");
      }
      else
      {
          Console.WriteLine("Minor");
      }
      
    • Switch Statement: A way to select one of many code blocks based on a value.

      int day = 3;
      switch (day)
      {
          case 1:
              Console.WriteLine("Monday");
              break;
          case 2:
              Console.WriteLine("Tuesday");
              break;
          case 3:
              Console.WriteLine("Wednesday");
              break;
          default:
              Console.WriteLine("Invalid day");
              break;
      }
      
    • Loops: Used to repeat a block of code multiple times.

      • for, while, do-while
      for (int i = 1; i <= 5; i++)
      {
          Console.WriteLine(i); // Prints 1, 2, 3, 4, 5
      }
      

    5. Methods (Functions)

    Methods are blocks of code designed to perform a specific task. Methods in C# can return a value or be void (meaning they don’t return anything). They can also take parameters.

    Example of a method with parameters and a return value:

    int AddNumbers(int a, int b)
    {
        return a + b;
    }
    
    int result = AddNumbers(5, 10); // result will be 15
    

    6. Classes and Objects

    C# is an object-oriented language, which means it uses classes to define objects. A class is a blueprint for creating objects, and an object is an instance of a class.

    Example:

    class Person
    {
        public string Name;
        public int Age;
    
        public void Introduce()
        {
            Console.WriteLine("Hello, my name is " + Name + " and I am " + Age + " years old.");
        }
    }
    
    class Program
    {
        static void Main()
        {
            Person person1 = new Person(); // Creating an object
            person1.Name = "Alice";
            person1.Age = 30;
            person1.Introduce(); // Prints: Hello, my name is Alice and I am 30 years old.
        }
    }
    

    7. Object-Oriented Principles

    C# supports key object-oriented programming principles, including:

    • Encapsulation: Grouping related data (fields) and methods in a class. C# also supports access modifiers (public, private, protected) to control the visibility of members.

      Example:

      class Car
      {
          private string model;
      
          public void SetModel(string model)
          {
              this.model = model;
          }
      
          public string GetModel()
          {
              return model;
          }
      }
      
    • Inheritance: A class can inherit members (fields, methods) from another class, allowing for code reuse and extension.

      Example:

      class Animal
      {
          public void Eat()
          {
              Console.WriteLine("Eating...");
          }
      }
      
      class Dog : Animal
      {
          public void Bark()
          {
              Console.WriteLine("Woof!");
          }
      }
      
    • Polymorphism: Allows objects to be treated as instances of their parent class, enabling method overriding and method overloading.

      Example:

      class Animal
      {
          public virtual void MakeSound()
          {
              Console.WriteLine("Some generic sound");
          }
      }
      
      class Dog : Animal
      {
          public override void MakeSound()
          {
              Console.WriteLine("Woof!");
          }
      }
      
      Animal myDog = new Dog();
      myDog.MakeSound(); // Prints "Woof!"
      
    • Abstraction: Hiding the implementation details and exposing only the essential parts of an object.

      Example using an interface:

      interface IAnimal
      {
          void Speak();
      }
      
      class Dog : IAnimal
      {
          public void Speak()
          {
              Console.WriteLine("Woof!");
          }
      }
      

    8. Collections

    In C#, collections are used to store groups of related objects. Some common collection types include:

    • Arrays: Fixed-size collections of elements.

      int[] numbers = { 1, 2, 3, 4, 5 };
      
    • Lists: Flexible, dynamically-sized collections that can grow or shrink.

      List<int> numbers = new List<int> { 1, 2, 3 };
      numbers.Add(4);
      

    Conclusion

    C# is a powerful and versatile programming language that enables developers to build a wide range of applications. It follows the principles of object-oriented programming (OOP) and is built on a strong foundation of type safety and modern development practices. With its simple syntax, extensive libraries, and robust development environment, C# is an excellent choice for developing applications for the .NET platform.

    Previous topic 5
    .Net Assembly
    Next topic 7
    Boxing and Unboxing

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time6 min
      Word count1,086
      Code examples0
      DifficultyIntermediate