- 전체
- Native Apps
- WinJS App
- C# Apps
- XAML
- VB.net
- VisualC.net
- C++
- MFC
- visual studio mobile app dev
- Azure ms cloud service
- Asp.net
- 인공지능 (AI)
- wpf
- UWP
- MAUI
- asp.net
C# Apps Using C# reflection to call a constructor
2017.06.25 15:19
Using C# reflection to call a constructor
I don't think GetMethod will do it, no - but GetConstructor will.
using System;
using System.Reflection;
class Addition
{
public Addition(int a)
{
Console.WriteLine("Constructor called, a={0}", a);
}
}
class Test
{
static void Main()
{
Type type = typeof(Addition);
ConstructorInfo ctor = type.GetConstructor(new[] { typeof(int) });
object instance = ctor.Invoke(new object[] { 10 });
}
}
[출처] https://stackoverflow.com/questions/3255697/using-c-sharp-reflection-to-call-a-constructor
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 3 |
Get started with Ionic 2 apps in Visual Studio
| 졸리운_곰 | 2016.11.20 | 1512 |
| 2 | How to: Ionic in Visual Studio | 졸리운_곰 | 2016.05.09 | 594 |
| 1 | Get started with Ionic apps in Visual Studio : 비주얼 스투이오로 모바일 앱 생성 ionic 프레임워크 | 졸리운_곰 | 2016.05.09 | 329 |

