Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Но, умение к месту применять паттерны и писать KISS код гораздо важнее вызубренного msdn имхо.
xxx: седня узнал новое понятие из словаря разработчиков дойчебанка — заниматься дусамфингом
xxx: пример: — Чем этот чилавег у вас там занимается уже полгода? Ответ: Ай ду нот ноу, ду самфинг
xxx: есть целые команды, которые занимаются дусамфингом
xxx: это распространено
I.8.9.5 Class type definitionТри отмеченных пункта делают вариант ответа №1 неверным.
…
An explicit class definition:
…
- Can optionally specify a method (called .cctor) to be called to initialize the type.
The semantics of when and what triggers execution of such type initialization methods, is as
follows:
- A type can have a type-initializer method, or not.
- A type can be specified as having a relaxed semantic for its type-initializer method
(for convenience below, we call this relaxed semantic BeforeFieldInit).- If marked BeforeFieldInit then the type’s initializer method is executed at, or
sometime before, first access to any static field defined for that type.- If not marked BeforeFieldInit then that type’s initializer method is executed at (i.e.,
is triggered by):
- first access to any static field of that type, or
- first invocation of any static method of that type, or
- first invocation of any instance or virtual method of that type if it is a value
type or- first invocation of any constructor for that type.
- Execution of any type's initializer method will not trigger automatic execution of
any initializer methods defined by its base type, nor of any interfaces that the type
implements.
For reference types, a constructor has to be called to create a non-null instance. Thus, for
reference types, the .cctor will be called before instance fields can be accessed and methods can
be called on non-null instances.
…
If a language wishes to provide more rigid behavior—e.g., type initialization automatically
triggers execution of base class’s initializers, in a top-to-bottom order—then it can do so by
either:
...
- by making explicit calls to
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor
namespace System::Customizer
{
public class Foo { }
}
Type.GetField()
, с ним можно взаимодействовать командой ldfld
только если у этого поля флаг IsLiteral == false
. В противном случае необходимо разрешать значение на уровне компилятора и прошивать его значение константой — иначе вылезает MissingFieldException
.[System.Diagnostics.Conditional("TEST")]
public void Test()
{
MessageBox.Show("I want cookie");
}
ctor()
{
this.Test();
this.GetType().InvokeMember("Test", BindingFlags.InvokeMethod, null, this, null);
}
[Obsolete]
public ObsoleteAttribute()
{
this._message = null;
this._error = false;
}
Несколько вопросов по .NET и C# (ответы с разбором)