TGViewer
Channel Public Channel
C# 1001 notes

C# 1001 notes

@csharp_1001_notes

Регулярные короткие заметки по C# и .NET.

Просто о сложном для каждого.

admin - @haarrp
Subscribers
6.66K
Photos
416
Videos
14
Links
364

Showing posts older than #257 · Back to latest

Older Posts 20 shown
Post #255 1.06K
📝 What is scope of a Protected Internal member variable of a C# class?

The protected internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application. This is also used while implementing inheritance.
Post #254 1.15K
​​❓What are the different types of serialization?

Following are the three different types of serialization:

- XML serialization: All the public properties are serialized to the XML document.

- SOAP: Any system that understands SOAP can use this serialization. System.Runtime.Serialization is the place where all the classes reside.

- Binary serialization: It is used for the conversion of any code into binary form.
Post #252 960
📝 What is the best practice to have best performance using Lazy objects?

You typically use it when you want to instantiate something the first time its actually used. This delays the cost of creating it till if/when it's needed instead of always incurring the cost.

Usually this is preferable when the object may or may not be used and the cost of constructing it is non-trivial.

For example Lazy<T> makes implementing lazy, thread-safe singletons easy.
Post #251 1.08K
​​❓State the difference between the “throw” and “throw ex” in .NET

The difference between “throw” and “throw ex” is that “throw” is used for preserving original error stack whereas “throw ex” has a throw point through which it can trace the stack. For more accurate, error-free information, the throw is advisable to use.
Post #248 913
📝 Can you create a function in C# which can accept varying number of arguments?

By using the params keyword, you can specify a method parameter that takes a variable number of arguments. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. The declared type of the params parameter must be a single-dimensional array.
Post #247 1.05K
❓State the difference between is and as operators in C#

The difference between is and as an operator in C# is that is the operator is used for checking the compatibility of an object for a given type and returning to the Boolean for the results.Whereas as the operator is used for casting of an object to a type or to a class.

https://youtu.be/IKmRtJcRX_I
YouTube IS vs AS Keyword | C# Interview Questions with Answers | Csharp Interview Questions | IS vs AS in C# See our other Step by Step video series below :- For more such videos visit http://www.questpond.com For more such videos subscribe https://www.youtube.com/questpondvideos See our other Step by Step video series below :- JavaScript Interview Questions: h…
Post #245 947
📝 What is the difference between is and as operators in C#?

The is operator checks if an object can be cast to a specific type.

 if (someObject is StringBuilder) ...

The as operator attempts to cast an object to a specific type, and returns null if it fails.

StringBuilder b = someObject as StringBuilder;
if (b != null) ...
Post #244 1.18K
❓What are the fundamental concepts of OOP?

OOP stands for Object-Oriented Programming and the following are the fundamental concepts:

- Encapsulation: It is the internal representation of an object which is hidden from the outside view of an object’s definition. Only required information is accessed while the other data are hidden.

- Abstraction: It is defined as the process of identifying critical behavior, eliminating the irrelevant details and data of an object.

- Inheritance: It is defined as the process of creating new classes from another class. This can be achieved by accessing, modifying, and extending the behavior of the objects in their parent class.

- Polymorphism: It is a term used for describing one name in many forms. It can be achieved through the same name but different implementations.

https://youtu.be/m_MQYyJpIjg
YouTube Fundamental Concepts of Object Oriented Programming This video reviews the fundamental concepts of Object Oriented Programming (OOP), namely: Abstraction, which means to simplify reality and focus only on the data and processes that are relevant to the application being built; Encapsulation meaning that data…
Post #241 985
📝 What is the difference between dispose and finalize methods in C#?

Finalizer and Dispose both are used for same task like to free unmanaged resources but have some differences see.

Finalize:

🔸 Finalize used to free unmanaged resources those are not in use like files, database connections in application domain and more, held by an object before that object is destroyed.

🔸 In the Internal process it is called by Garbage Collector and can't called manual by user code or any service.

🔸 Finalize belongs to System.Object class.

🔸 Implement it when you have unmanaged resources in your code, and make sure that these resources are freed when the Garbage collection happens.

Dispose:

🔸 Dispose is also used to free unmanaged resources those are not in use like files, database connections in Application domain at any time.

🔸 Dispose explicitly it is called by manual user code.

🔸 If we need to dispose method so must implement that class by IDisposable interface.
Post #240 1.04K
​​❓Explain the difference between managed and unmanaged code

MANAGED CODE is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.

On the other hand, UMANAGED CODE is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually. In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.
Post #237 914
📝 What is the Constructor Chaining in C#?

Constructor Chaining is an approach where a constructor calls another constructor in the same or base class. This is very handy when we have a class that defines multiple constructors.
Post #235 1.11K
​​❓Discuss the difference between constants and read-only variables

While constants and read-only variable share many similarities, there are some important differences:

- Constants are evaluated at the compile-time, while the read-only variables are evaluated at the runtime.

- Constants support only value-type variables, while read-only variables can hold reference type variables.

- Constants should be used when the value is not changing during the runtime, and read-only variables are used mostly when their actual value is unknown before the runtime.
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →