Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
QuestionHow to Access Methods and Properties of a Private Class Pin
namelkcip30-Sep-11 19:24
namelkcip30-Sep-11 19:24 
AnswerRe: How to Access Methods and Properties of a Private Class Pin
Dave Kreskowiak1-Oct-11 2:43
mveDave Kreskowiak1-Oct-11 2:43 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
SledgeHammer011-Oct-11 8:18
SledgeHammer011-Oct-11 8:18 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
Dave Kreskowiak1-Oct-11 8:41
mveDave Kreskowiak1-Oct-11 8:41 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
Eddy Vluggen1-Oct-11 8:42
professionalEddy Vluggen1-Oct-11 8:42 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
SledgeHammer011-Oct-11 9:58
SledgeHammer011-Oct-11 9:58 
AnswerRe: How to Access Methods and Properties of a Private Class Pin
Eddy Vluggen1-Oct-11 11:49
professionalEddy Vluggen1-Oct-11 11:49 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
Eddy Vluggen1-Oct-11 12:47
professionalEddy Vluggen1-Oct-11 12:47 
C#
using System;
using System.Diagnostics;
using System.Reflection;
namespace ConsoleApplication7
{
static class Owner
{
    private class SomeClass
    {
        private string SomeMethod()
        { return "Hello world"; }
    }
}
class Program
{
    static int Main(string[] args)
    {
        Type ownerClassType = Type.GetType(
            "ConsoleApplication7.Owner, ConsoleApplication7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
        Type someClassType = ownerClassType.GetNestedType(
            "SomeClass", 
            BindingFlags.Instance | BindingFlags.NonPublic);
        Object someObject = Activator.CreateInstance(someClassType);
        MethodInfo mi = someClassType.GetMethod(
            "SomeMethod",
            BindingFlags.Instance | BindingFlags.NonPublic);
        Object result = mi.Invoke(someObject, null);
        Console.WriteLine(result);
        Console.ReadKey();
        return 0;
    }
}
}

Yup, works Smile | :)
Bastard Programmer from Hell Suspicious | :suss:

GeneralRe: How to Access Methods and Properties of a Private Class Pin
BillWoodruff1-Oct-11 18:30
professionalBillWoodruff1-Oct-11 18:30 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
namelkcip1-Oct-11 16:33
namelkcip1-Oct-11 16:33 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
BillWoodruff1-Oct-11 18:32
professionalBillWoodruff1-Oct-11 18:32 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
Dave Kreskowiak2-Oct-11 1:54
mveDave Kreskowiak2-Oct-11 1:54 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
BobJanova2-Oct-11 22:28
BobJanova2-Oct-11 22:28 
GeneralRe: How to Access Methods and Properties of a Private Class Pin
namelkcip5-Oct-11 16:56
namelkcip5-Oct-11 16:56 
AnswerRe: How to Access Methods and Properties of a Private Class Pin
PIEBALDconsult1-Oct-11 4:01
mvePIEBALDconsult1-Oct-11 4:01 
QuestionReceiving Data on Socket Class Pin
Richard Andrew x6430-Sep-11 13:23
professionalRichard Andrew x6430-Sep-11 13:23 
AnswerRe: Receiving Data on Socket Class Pin
André Kraak30-Sep-11 13:48
André Kraak30-Sep-11 13:48 
GeneralRe: Receiving Data on Socket Class Pin
Richard Andrew x6430-Sep-11 14:23
professionalRichard Andrew x6430-Sep-11 14:23 
QuestionGridView Template Field Value Pin
jashimu30-Sep-11 10:01
jashimu30-Sep-11 10:01 
AnswerRe: GridView Template Field Value Pin
Eddy Vluggen30-Sep-11 11:26
professionalEddy Vluggen30-Sep-11 11:26 
AnswerRe: GridView Template Field Value Pin
Perić Željko6-Oct-11 3:36
professionalPerić Željko6-Oct-11 3:36 
QuestionSettings/reading files attributes Pin
devvvy30-Sep-11 0:07
devvvy30-Sep-11 0:07 
AnswerRe: Settings/reading files attributes Pin
Pete O'Hanlon30-Sep-11 0:44
mvePete O'Hanlon30-Sep-11 0:44 
QuestionConstructing a Generic Class from several similar classes Pin
Wayne Gaylard29-Sep-11 23:21
professionalWayne Gaylard29-Sep-11 23:21 
AnswerRe: Constructing a Generic Class from several similar classes Pin
Pete O'Hanlon29-Sep-11 23:50
mvePete O'Hanlon29-Sep-11 23:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.