Author Archives: Stanislav_Panteleev

С#. Attributes. Practice

This example shows -reading attributes -initialize object in dependence of attributes value -reading attributes from class and from properties -early binding / late binding examples -iteration through types

Numbers

CarLib

 

Posted in C# | Comments Off on С#. Attributes. Practice

C#. Attributes

Definition Attributes – descendants of System.Attribute, some kind of annotations of code, applied for some object. Standart attributes are [CLSCompliant] – Common Language Specification [DLLImport] [Obsolete] – deprecated [Serializable] [NonSerialized] [WebMethod] Self made attributes also possible Attribute consumers Compiler, some … Continue reading

Posted in C# | Comments Off on C#. Attributes

С#. LateBindingExamples

Late binding means – we can create instance not in compilation time but in execution and call methods with or without params -invoke methods with / without params -setting private fields

 

Posted in C# | Comments Off on С#. LateBindingExamples

C#. Dynamically loaded assembly

Load and LoadFrom commands…

This will give

 

Posted in C# | Comments Off on C#. Dynamically loaded assembly

C#. Reflection

Reflection – getting info about type during execution.

#1 Need instance and info about type, before getting type

#2 Need info about type before getting type

#3 in current assembly with string param

#4 in external … Continue reading

Posted in C# | Comments Off on C#. Reflection

C#. Shared assembly

Lets use Carlib.dll from One file Assembly 1. Strong name Properties – > Signing – > Sign the assembly -> New – > SomeName (for ex. myKeyPair.snk) 2.  Install assembly to GAC (Global Assembly Cache) go to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio … Continue reading

Posted in C# | Comments Off on C#. Shared assembly

С#. Assembly theory

Assembly – versioned (for ex. 1.0.0.0), self described( has manifest, links to other external assemblies, info about all types) binary, supported by CLR (Common Language Runtime). One EXE is divided in may exe, dll files. Assembly defines type borders.  Example. … Continue reading

Posted in C# | Comments Off on С#. Assembly theory

C#. Creating one file assembly. Example

Lets create CarLibrary.dll assembly File NewProject ClassLibrary

In other file Derived.cs 2 derived classes ClassView – addReference – System.Windows.Forms

Now lets create new project CarClient ClassView – addReference – Browse –  CarLibrary.dll

 

Posted in C# | Comments Off on C#. Creating one file assembly. Example

C#. Namespace examples

123

Circle.cs

Hexagon.cs

Square.cs

 

Posted in C# | Comments Off on C#. Namespace examples

C#. Delegates, Func, Action

Ну, есть ключевое слово delegate — это описание сигнатуры функции, т. е., её списка параметров и типа возвращаемого значения. Используется так:

Им можно пользоваться так:

С другой стороны, есть готовые, предопределённые сигнатуры функций (Func<TArg1, TArg2, …, TResult> с возвращаемым … Continue reading

Posted in C# | Comments Off on C#. Delegates, Func, Action