Изменения документа Сценарии

Редактировал(а) Alexandr Fokin 2026/03/17 19:05

От версии 1.6
отредактировано Alexandr Fokin
на 2023/05/31 09:59
Изменить комментарий: К данной версии нет комментариев
К версии 1.9
отредактировано Alexandr Fokin
на 2026/03/17 19:00
Изменить комментарий: К данной версии нет комментариев

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -1,5 +1,9 @@
1 -|(% style="width:174px" %) |(% style="width:1348px" %)Find Types in All Assemblies
1 +|(% style="width:174px" %)Поиск типа|(% style="width:1348px" %)(((
2 +|Find Types in All Assemblies
2 2  [[https:~~/~~/stackoverflow.com/questions/4692340/find-types-in-all-assemblies>>https://stackoverflow.com/questions/4692340/find-types-in-all-assemblies]]
4 +|{{code language="c#"}}var assemblyQualifiedName = type.AssemblyQualifiedName;
5 +Type.GetType(assemblyQualifiedName, throwOnError: false){{/code}}
6 +)))
3 3  |(% style="width:174px" %) |(% style="width:1348px" %)(((
4 4  Find a private field with Reflection?
5 5  [[https:~~/~~/stackoverflow.com/questions/95910/find-a-private-field-with-reflection>>https://stackoverflow.com/questions/95910/find-a-private-field-with-reflection]]
... ... @@ -10,7 +10,7 @@
10 10  Invoke method by MethodInfo
11 11  [[https:~~/~~/stackoverflow.com/questions/919826/invoke-method-by-methodinfo>>https://stackoverflow.com/questions/919826/invoke-method-by-methodinfo]]
12 12  )))
13 -|(% style="width:174px" %)Получение типа независимо от nullable|(% style="width:1348px" %){{code language="c#"}}PropertyInfo prop;
17 +|(% style="width:174px" %)Получение основного типа для nullable структур.|(% style="width:1348px" %){{code language="c#"}}PropertyInfo prop;
14 14  var type = Nullable.GetUnderlyingType(prop.PropertyType)
15 15   ?? prop.PropertyType;{{/code}}
16 16  |(% style="width:174px" %)Формирование конкретного типа на основе Generic|(% style="width:1348px" %)(((
... ... @@ -20,5 +20,17 @@
20 20  C# Type MakeGenericType
21 21  [[http:~~/~~/www.java2s.com/Tutorials/CSharp/System/Type/C_Type_MakeGenericType.htm>>http://www.java2s.com/Tutorials/CSharp/System/Type/C_Type_MakeGenericType.htm]]
22 22  )))
27 +|(% style="width:174px" %)Ref и Out параметры метода.|(% style="width:1348px" %)(((
28 +| |При передаче параметра с использованием out и ref, в качестве типа используется дополнительная обертка.
29 +Критерий передачи {{code language="c#"}}parameter.ParameterType.IsByRef{{/code}}.
30 +| |What is the opposite of Type.MakeByRefType
31 +[[https:~~/~~/stackoverflow.com/questions/607130/what-is-the-opposite-of-type-makebyreftype>>https://stackoverflow.com/questions/607130/what-is-the-opposite-of-type-makebyreftype]]
32 +| |{{code language="c#"}}// Получение типа обертки.
33 +var refType = typeof(int).MakeByRefType()
23 23  
35 +// Разворачивание, получение основного типа.
36 +// Также флаг refType.HasElementType.
37 +refType.GetElementType();{{/code}}
38 +)))
39 +
24 24