Click here to Skip to main content
14,733,641 members
Home » Discussions » C#
   

C#

 
QuestionString manipulation Pin
vinoth.cv130-Jul-08 1:01
Membervinoth.cv130-Jul-08 1:01 
AnswerRe: String manipulation Pin
Simon P Stevens30-Jul-08 1:19
MemberSimon P Stevens30-Jul-08 1:19 
GeneralRe: String manipulation Pin
leppie30-Jul-08 1:26
Memberleppie30-Jul-08 1:26 
GeneralRe: String manipulation Pin
Simon P Stevens30-Jul-08 1:31
MemberSimon P Stevens30-Jul-08 1:31 
AnswerRe: String manipulation Pin
PIEBALDconsult30-Jul-08 5:26
professionalPIEBALDconsult30-Jul-08 5:26 
QuestionCTRL+C and CTRL+V in grid control Pin
eli1502197930-Jul-08 0:51
Membereli1502197930-Jul-08 0:51 
AnswerRe: CTRL+C and CTRL+V in grid control Pin
paas30-Jul-08 5:25
Memberpaas30-Jul-08 5:25 
QuestionGet method name as string Pin
Nicholas Butler30-Jul-08 0:36
sitebuilderNicholas Butler30-Jul-08 0:36 
Some methods in the framework take the name of a method as a string, e.g. ObjectDataSource and most of WPF. I don't like this as the compiler and IDE tools can't link the string and the method. So I want to generate the string from the token. I came up with this:

class TestClass
{
  public static void Test()
  {
    string s = GetName<string,int>( Method );
  }
 
  static int Method( string s ) { return 0; }
 
  static string GetName<T,TResult>( Func<T,TResult> method )
  {
    return method.Method.Name;
  }
 
  ...
  GetName overloads for Actions and Funcs
  ...
}


This is ok, but I don't like having to specify the generic types when calling GetName.

I don't think there's a way around this, because method groups don't participate in type inferencing.

So my question is: is there a better way?

Thanks

Nick

----------------------------------
Be excellent to each other Smile | :)

AnswerRe: Get method name as string Pin
leppie30-Jul-08 1:22
Memberleppie30-Jul-08 1:22 
GeneralRe: Get method name as string Pin
Nicholas Butler30-Jul-08 1:36
sitebuilderNicholas Butler30-Jul-08 1:36 
AnswerRe: Get method name as string Pin
DaveyM6930-Jul-08 2:09
professionalDaveyM6930-Jul-08 2:09 
GeneralRe: Get method name as string Pin
leppie30-Jul-08 3:27
Memberleppie30-Jul-08 3:27 
QuestionControl.Invoke() equivalent with Thread object Pin
ccufi30-Jul-08 0:36
Memberccufi30-Jul-08 0:36 
AnswerRe: Control.Invoke() equivalent with Thread object Pin
Frank Horn30-Jul-08 1:36
MemberFrank Horn30-Jul-08 1:36 
AnswerRe: Control.Invoke() equivalent with Thread object Pin
Alan N30-Jul-08 5:55
MemberAlan N30-Jul-08 5:55 
QuestionHow to run application from network folder Pin
AndrusM30-Jul-08 0:12
MemberAndrusM30-Jul-08 0:12 
AnswerRe: How to run application from network folder Pin
Simon P Stevens30-Jul-08 0:47
MemberSimon P Stevens30-Jul-08 0:47 
GeneralRe: How to run application from network folder Pin
AndrusM30-Jul-08 1:25
MemberAndrusM30-Jul-08 1:25 
GeneralRe: How to run application from network folder Pin
Simon P Stevens30-Jul-08 2:16
MemberSimon P Stevens30-Jul-08 2:16 
GeneralRe: How to run application from network folder Pin
AndrusM30-Jul-08 2:22
MemberAndrusM30-Jul-08 2:22 
GeneralRe: How to run application from network folder Pin
Simon P Stevens30-Jul-08 2:34
MemberSimon P Stevens30-Jul-08 2:34 
GeneralRe: How to run application from network folder Pin
AndrusM30-Jul-08 8:25
MemberAndrusM30-Jul-08 8:25 
GeneralRe: How to run application from network folder Pin
Simon P Stevens30-Jul-08 22:30
MemberSimon P Stevens30-Jul-08 22:30 
GeneralRe: How to run application from network folder Pin
AndrusM30-Jul-08 23:38
MemberAndrusM30-Jul-08 23:38 
GeneralRe: How to run application from network folder Pin
AndrusM30-Jul-08 2:35
MemberAndrusM30-Jul-08 2:35 

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.