C-Sharp Flashcards
20 Questions
100 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What are custom exceptions?

Custom exceptions are user-defined exceptions that are raised when business rules of an application are violated.

What is the difference between managed and unmanaged code?

Managed code is executed by the CLR of the .NET Framework, while unmanaged code is executed by the Operating System.

What is a variable in C#?

A variable is a container for storing data values, which can be defined using different keywords.

What is an object in C#?

<p>An object is a real-world entity that has state (data) and behavior (functionality), created at runtime.</p> Signup and view all the answers

What is a class in C#?

<p>A class is a blueprint for creating objects, also known as object constructors.</p> Signup and view all the answers

What is a struct in C#?

<p>A struct is a value type that holds related data of various data types, created using the struct keyword.</p> Signup and view all the answers

A sealed class can be inherited.

<p>False</p> Signup and view all the answers

What is a partial class?

<p>A partial class allows breaking the functionality of a single class into multiple files.</p> Signup and view all the answers

What is an enum in C#?

<p>An enum is a special class that represents a group of constants.</p> Signup and view all the answers

What does the using statement do in C#?

<p>The using statement ensures correct use of IDisposable objects, making them read-only within the block.</p> Signup and view all the answers

Which of the following are access modifiers in C#? (Select all that apply)

<p>Protected</p> Signup and view all the answers

What is a constructor in C#?

<p>A constructor is a special method used to initialize objects when a class instance is created.</p> Signup and view all the answers

What is a method in C#?

<p>A method is a block of code within a class or structure that performs specific operations.</p> Signup and view all the answers

What are delegates in C#?

<p>A delegate is a type that holds references to methods with a specific parameter list and return type.</p> Signup and view all the answers

What is an event handler in C#?

<p>An event handler is a method that executes in response to a specific event in an application.</p> Signup and view all the answers

What are the types of delegates?

<p>Types of delegates include single delegate, multicast delegate, and generic delegate.</p> Signup and view all the answers

What is the difference between a virtual and abstract method in C#?

<p>A virtual method can be redefined in derived classes, while an abstract method has no implementation.</p> Signup and view all the answers

What is the static keyword in C#?

<p>The static keyword defines members that belong to the class itself rather than to any specific object.</p> Signup and view all the answers

What does LINQ stand for in C#?

<p>LINQ stands for Language-Integrated Query.</p> Signup and view all the answers

What is a record in C#?

<p>A record is a special type of class or struct that provides syntax for working with immutable data.</p> Signup and view all the answers

Study Notes

Custom Exceptions

  • Custom exceptions allow raising specific errors when business rules are violated within an application.

Managed vs Unmanaged Code

  • Managed code runs under the Common Language Runtime (CLR) of the .NET Framework.
  • Unmanaged code operates directly through the Operating System (OS).
  • CLR provides built-in security for managed code; developers must ensure the safety of unmanaged code.

Variables in C#

  • Variables act as containers for storing data values, each defined by specific keywords.
  • Categories of variables include:
    • Static variables
    • Instance variables
    • Array elements
    • Value parameters
    • Reference parameters
    • Output parameters
    • Local variables

Objects in C#

  • An object represents a real-world entity, such as a chair or car, encapsulating state (data) and behavior (functionality).
  • Objects are created at runtime.

Class in C#

  • A class serves as a blueprint for creating objects, with instances of the class being referred to as objects.

Structures in C#

  • A structure is a value type used to hold related data of various types within a single variable.
  • The struct keyword is used to define a structure, which typically represents a record.

Sealed Class

  • A sealed class cannot be inherited from, providing a way to maintain encapsulation.

Partial Class

  • A partial class allows the splitting of a single class's functionality across multiple files for better organization.

Enums in C#

  • An enum is a special class that represents a set of constants.
  • Example of an enum declaration:
    enum Level {
        Low,
        Medium,
        High
    }
    

Using Statement in C#

  • The using statement ensures proper handling of IDisposable objects.
  • Within a using block, the object is read-only and cannot be modified.

Access Modifiers

  • Public: Full access
  • Protected-internal: Accessible in the same assembly and derived classes
  • Protected: Accessible only in derived classes
  • Internal: Accessible in the same assembly
  • Private-protected: Accessible in derived classes within the same assembly
  • Private: Accessible only within the class

Constructor in C#

  • A constructor is a special method called when an object is created to initialize it.
  • Used to set initial values for class fields.

Methods in C#

  • Methods are blocks of code within classes or structures that perform specific operations and facilitate code reusability.

Delegates

  • A delegate is a type that holds references to methods with specified parameter lists and return types.
  • Facilitates method invocation at runtime.

Event Handlers in C#

  • An event handler is a method designed to execute in response to specific application events.

Types of Delegates

  • Single delegate: Invokes a single method.
  • Multicast delegate: Invokes multiple methods using + or - operators.
  • Generic delegate: Does not require an instance.
  • Common types include Action, Func, and Predicate.

Virtual vs Abstract Methods

  • A virtual method can be overridden in derived classes using the override keyword.
  • An abstract method has no implementation and must be defined within abstract classes.

Static Keyword

  • A static class can only contain static members, methods, and constructors.
  • Objects of a static class cannot be created; static members are shared across all instances.
  • Static variables are accessed via the class name without needing an instance.

LINQ (Language-Integrated Query)

  • LINQ allows for data access and manipulation from various sources like objects, data sets, SQL Server, and XML.
  • Common LINQ methods include Where, Select, Any, All, GroupBy, FirstOrDefault, Last, SingleOrDefault, and OrderBy.

Records in C#

  • Records are used for immutable data storage, providing special syntax and behaviors for data management.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

Test your knowledge on C-Sharp concepts with these flashcards. Learn about custom exceptions and the differences between managed and unmanaged code. Perfect for reinforcing your understanding of C-Sharp programming principles.

More Like This

Use Quizgecko on...
Browser
Browser