C#

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Structs fall into these categories:

- Numeric types - Integral types - Floating-point types - decimal - bool - User defined structs.

The C# typing system contains the following categories:

- Value types - Reference types - Pointer types

The following keywords are used to declare reference types:

- class - interface - delegate

Does C# require the use of Pointers?

A reference type stores a reference to the location in memory of the object. . If you are familiar with C/C++ then you can think of a reference to the memory location to be the same as a pointer. C# does not require you to use pointers.

Describe Child Classes:

Accessing private members of Child from Main would only be possible if Main were a member of the class. Types declared inside a class without an access modifier default to private, so the data members in this example would still be private if the keyword were removed. Finally, notice that for the object created using the default constructor (child3), the age field was initialized to zero by default.

How do Data Types work?

All applications store and manipulate data within the computer's memory. C# supports two kinds of data types used to represent real-world information. Value types are so-called because they contain the actual value of the data they store. For example, you might have an int type that stores the value 3. The literal value of 3 is stored in the variable that you declare to hold it.

How are classes Declared?

Classes are declared using the keyword class, as shown in the following example: class TestClass { // Methods, properties, fields, events, delegates // and nested classes go here. }

Describe Classes (hint: internal and external)

Classes that you declare directly within a namespace, not nested within other classes, can be either public or internal. Classes are internal by default. Class members, including nested classes, can be public, protected internal, protected, internal, or private. Members are private by default.

A class can contain declarations of the following members:

Constructors Destructors Constants Fields Methods Properties Indexers Operators Events Delegates Classes Interfaces Structs

Describe the " Int " Data type:

Description: Whole numbers Size (BYTES): 4 .NETTYPE: System.Int32 RANGE: -2,147,483,648 to 2,147,483,647

Give example of Inheritance types ( None, Single,, none that implements 2 interfaces, Single impliments one interface)

Inheritance Example *None: class ClassA { } *Single: class DerivedClass: BaseClass { } *None, implements two interfaces: class ImplClass: IFace1, IFace2 { } * Single, implements one interface: class ImplDerivedClass: BaseClass, IFace1 { }

Describe inheritance:

Only single inheritance is allowed in C#. In other words, a class can inherit implementation from one base class only. However, a class can implement more than one interface. The following table shows examples of class inheritance and interface implementation:

The value types consist of two main categories:

Structs Enumerations

Describe how to use the Ref Keyword

The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by reference is that any change to the parameter in the called method is reflected in the calling method. For example, if the caller passes a local variable expression or an array element access expression, and the called method replaces the object to which the ref parameter refers, then the caller's local variable or the array element now refer to the new object. Do not confuse the concept of passing by reference with the concept of reference types. The two concepts are not the same. A method parameter can be modified by ref regardless of whether it is a value type or a reference type. There is no boxing of a value type when it is passed by reference. To use a ref parameter, both the method definition and the calling method must explicitly use the ref keyword

Give a brief description of how Variables and Refrence types work.

Variables of reference types store references to their data (objects), while variables of value types directly contain their data. With reference types, two variables can reference the same object; therefore, operations on one variable can affect the object referenced by the other variable. With value types, each variable has its own copy of the data, and it is not possible for operations on one variable to affect the other (except in the case of ref and out parameter variables, see ref (C# Reference) and out parameter modifier (C# Reference)).

Describe CLR (Common Language Runtime)

Your application executes on the target computing platform through the use of the Common Language Runtime (CLR). This also means that C# is a Just-in-Time (JIT) compiled language. The common language runtime is the foundation of the .NET Framework. The runtime is responsible for managing your code at execution time. It provides core services such as memory management, thread management, and remoting. The CLR enforces strict type safety and provides security and robustness for managed applications.

There are two kinds of types in C#

reference types and value types


संबंधित स्टडी सेट्स

Bill of Rights - First 10 Amendments of the Constitution

View Set

Study Guide - Unit 3 (English Civil War and Glorious Revolution)

View Set

MGMT 3140-H01: Chapter 11. Managing the Diverse Workforce

View Set

Last min Grammar - Study Sections

View Set

Managing Human Resources Chapter 9 Managing Compensation

View Set

HS326 Chapter 4 and 5: Profit Sharing Plans, Stock Bonus Plans, Stock Ownership Plans/// Distributions From Qualified Plans

View Set

Business Law for Managers Mindtap Questions

View Set

Linux Filesystem Administration (review questions) - [LINUX System Administration]

View Set