C# C# and .NET Fundamentals

Introduction to .NET, C# Syntax, Variables, Constants and Data Types

This topic introduces the evolution of programming languages from C and C++ to Java and the Microsoft .NET platform. It explains applications, the .NET Framework and .NET editions, CLR, FCL, BCL, the .NET compilation process, managed and unmanaged code, and fundamental C# concepts such as variables, constants, naming conventions and data types.

Beginner 90 Minutes Monopoly IT Solutions Updated
.NET 10 class training banner
5.0
5.0
4.6

12 Noon Class

9 AM Class

10 AM Class

Overview

What you'll cover

Learning objectives

  • Understand the basic history of C, C++, Java and .NET
  • Understand standalone and network applications
  • Understand the purpose of the .NET platform
  • Understand .NET Framework and .NET Core as presented in the source
  • Understand the role of CLR, FCL and BCL
  • Understand the basic .NET application compilation process
  • Differentiate managed and unmanaged code
  • Understand C# variables and their syntax
  • Apply C# variable naming rules
  • Understand C# naming conventions
  • Understand constants
  • Understand the characteristics of data types
  • Understand value, reference, nullable and dynamic types

Prerequisites

  • Basic computer knowledge
  • Basic programming concepts
  • Understanding of memory and values
  • Basic familiarity with programming languages

Related topics

  • C# Introduction
  • .NET Introduction
  • CLR
  • FCL
  • BCL
  • CTS
  • CLS
  • Managed Code
  • Unmanaged Code
  • C# Variables
  • C# Constants
  • C# Data Types
  • Value Types
  • Reference Types
  • Nullable Types
  • Dynamic Types
  • C# Naming Conventions
Theory

Concept breakdown

Syntax
Hands-on example

C# Variables, Constants and Data Types

Console Output
> "a = 10"
> "b = 20"
> "MAX_AGE = 40"
> "Employee Id = 101"
> "Salary = 50000.5"
> "Grade = A"
> "Is Active = True"
> "Amount = 10000.50"
> "Employee Name = Sathesh"
> "Optional Age = "
> "Dynamic x = Hello"
Walkthrough

Step by step

  1. 1

    Understand Programming Language History

    Review the source's timeline covering C, C++, Java, Visual Studio and .NET.

  2. 2

    Understand .NET

    Understand .NET as the Microsoft application development platform described in the source.

  3. 3

    Understand .NET Technologies

    Identify C#.NET, ADO.NET, LINQ, EF Core and ASP.NET Core and their roles as described in the source.

  4. 4

    Understand CLR

    CLR manages execution of .NET programs and provides runtime services such as memory management, security and exception handling.

  5. 5

    Understand FCL and BCL

    FCL provides framework classes and interfaces, while BCL is described in the source as a subset providing common functionality.

  6. 6

    Understand Compilation

    C# source code is compiled into an assembly containing MSIL and metadata, then JIT compiles the code into native machine code.

  7. 7

    Understand Managed Code

    Managed code is executed under the CLR/runtime environment.

  8. 8

    Create Variables

    Declare a variable, initialize it, or perform declaration and initialization together.

  9. 9

    Apply Naming Rules

    Use valid C# identifiers and follow the supplied naming conventions.

  10. 10

    Create Constants

    Use const when a value must remain fixed.

  11. 11

    Understand Data Types

    Learn the source's four data type categories: value, reference, nullable and dynamic types.

Summary

Key takeaways

Key points

  • C is described as a Procedure Oriented Programming language.
  • C++ is described as an Object Oriented Programming language.
  • Java is described in the source as an Internet Programming Language.
  • .NET is presented as a framework/platform for building applications.
  • The source identifies standalone and network applications.
  • C#.NET is associated with console, Windows and web applications.
  • ADO.NET is described as a data access technology.
  • LINQ stands for Language Integrated Query.
  • EF Core stands for Entity Framework Core and is described as an ORM.
  • ASP.NET Core is described as a cross-platform web framework.
  • CLR manages .NET program execution.
  • FCL provides framework classes and interfaces.
  • BCL is described as a subset of FCL.
  • C# source code is compiled and then JIT compiled to native code.
  • Variables can change during program execution.
  • Constants cannot be changed after declaration.
  • C# variable names are case sensitive.
  • Value, reference, nullable and dynamic types are covered in the source.

Advantages

  • Provides a foundation for understanding the .NET ecosystem.
  • Introduces the runtime, class libraries and compilation process.
  • Introduces fundamental C# syntax before advanced programming concepts.
  • Provides naming rules and conventions for writing maintainable C# code.
  • Introduces different data type categories.

Disadvantages

Real-world use

Variables, Constants and Data Types in Applications

Variables can store changing application data, constants can represent fixed values, and suitable C# data types can model employee, financial and optional values.

Interview prep

Frequently asked questions

The source describes .NET as a framework for building applications.

CLR stands for Common Language Runtime and manages the execution of .NET programs.

FCL stands for Framework Class Library and provides classes and interfaces used to build applications.

BCL stands for Base Class Library and is described in the source as a subset of FCL containing common functionality.

CTS stands for Common Type System.

CLS stands for Common Language Specification.

The source defines managed code as code executed by the CLR.

The source defines unmanaged code as code executed directly by the operating system and not managed by the CLR.

A variable is a name given to memory where a program can store a value that may change during execution.

The source states that a variable should start with an alphabet or underscore, may contain numbers but not start with a number, should not contain special characters except underscore, is case sensitive, and cannot use reserved keywords.

A constant is a fixed value that cannot be changed during program execution.

<data_type> <variable_name> = <initial_value>;

Value Types, Reference Types, Nullable Types and Dynamic Types.

Test yourself

Quick MCQ practice

1. What does CLR stand for?

2. What does FCL stand for?

3. What does BCL stand for?

4. What does LINQ stand for?

5. What does EF Core represent?

6. Which component manages the execution of .NET programs?

7. Which keyword is used to declare a constant?

8. Which of the following is a valid variable declaration?

9. Which category includes int, double and char according to the source?

10. Which category includes string, object and array according to the source?

11. Which syntax represents a nullable int?

12. Which keyword is used for dynamic typing?

Apply it

Practice on your own

Coding exercise

Variable Declaration and Initialization

Create variables for employee ID, employee name, salary and active status. Display their values.

Assignment

  1. Explain the difference between C, C++, Java and .NET as presented in the source.
  2. Write the programming language history timeline.
  3. Explain standalone and network applications.
  4. Explain CLR, FCL and BCL.
  5. Write the .NET application compilation process.
  6. Differentiate managed and unmanaged code.
  7. Write the syntax for declaring and initializing a variable.
  8. List all variable naming rules from the source.
  9. List the C# naming conventions.
  10. Create five examples of constants.
  11. Explain the four characteristics determined by a data type.
  12. Give examples of value, reference, nullable and dynamic types.
  13. Create a C# program demonstrating all four data type categories.

Tags

#csharp#c-sharp#dotnet#.net#dotnet-framework#clr#fcl#bcl#cts#cls#managed-code#unmanaged-code#csharp-variables#csharp-constants#csharp-data-types#value-types#reference-types#nullable-types#dynamic-types

References

getintouch

Book for Live Demo!