Click here to Skip to main content
15,904,877 members
Home / Discussions / C#
   

C#

 
GeneralRe: Conditional RunTime code Pin
Eddy Vluggen10-Sep-15 5:54
professionalEddy Vluggen10-Sep-15 5:54 
QuestionNew to programming--Help! Pin
Member 119729959-Sep-15 20:13
Member 119729959-Sep-15 20:13 
AnswerRe: New to programming--Help! Pin
OriginalGriff9-Sep-15 21:09
mveOriginalGriff9-Sep-15 21:09 
AnswerRe: New to programming--Help! Pin
Richard MacCutchan9-Sep-15 22:10
mveRichard MacCutchan9-Sep-15 22:10 
AnswerRe: New to programming--Help! Pin
F-ES Sitecore9-Sep-15 23:42
professionalF-ES Sitecore9-Sep-15 23:42 
AnswerRe: New to programming--Help! Pin
Afzaal Ahmad Zeeshan10-Sep-15 1:06
professionalAfzaal Ahmad Zeeshan10-Sep-15 1:06 
AnswerRe: New to programming--Help! Pin
Amarnath S10-Sep-15 1:56
professionalAmarnath S10-Sep-15 1:56 
Questionmaking an array of List Pin
sdecorme9-Sep-15 3:53
sdecorme9-Sep-15 3:53 
AnswerRe: making an array of List Pin
OriginalGriff9-Sep-15 4:17
mveOriginalGriff9-Sep-15 4:17 
AnswerRe: making an array of List Pin
Eddy Vluggen9-Sep-15 11:24
professionalEddy Vluggen9-Sep-15 11:24 
QuestionSecondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash9-Sep-15 2:10
santosh kumar dash9-Sep-15 2:10 
AnswerRe: Secondary Y-Axis not displayed in graph using c sharp Pin
Eddy Vluggen9-Sep-15 3:44
professionalEddy Vluggen9-Sep-15 3:44 
GeneralRe: Secondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash10-Sep-15 0:16
santosh kumar dash10-Sep-15 0:16 
Questioncalling T's method from a generic class Pin
binsafir7-Sep-15 23:36
binsafir7-Sep-15 23:36 
AnswerRe: calling T's method from a generic class Pin
Eddy Vluggen7-Sep-15 23:57
professionalEddy Vluggen7-Sep-15 23:57 
AnswerRe: calling T's method from a generic class Pin
Richard MacCutchan7-Sep-15 23:59
mveRichard MacCutchan7-Sep-15 23:59 
AnswerRe: calling T's method from a generic class Pin
Pete O'Hanlon8-Sep-15 0:07
mvePete O'Hanlon8-Sep-15 0:07 
AnswerRe: calling T's method from a generic class Pin
F-ES Sitecore8-Sep-15 0:24
professionalF-ES Sitecore8-Sep-15 0:24 
Generics are functions that work regardless of the type they are bound to. If you need to call a method then your function is no longer generic as it can't be used with any type. In order to do this your types will need to implement an interface that has your method on it

C#
public interface IMyInterface
{
    bool Compare(object target);
}

public class MyClass : IMyInterface
{
    public bool Compare(object target)
    {
        // implement this method properly
        return true;
    }
}


When defining your generic function you can now stipulate that the type used has to implement your interface

C#
private void MyFunction<T>(T data, T data2) where T : IMyInterface
{
    data.Compare(data2);
}


You can now call your generic method but it must be bound to an object that implements your interface, it is no longer 100% generic.

C#
MyFunction<MyClass>(new MyClass(), new MyClass()); // valid
MyFunction<SqlConnection>(new SqlConnection(), new SqlConnection()); // not valid as SqlConnection does not implement IMyInterface

AnswerRe: calling T's method from a generic class Pin
DanBecause9-Sep-15 18:03
DanBecause9-Sep-15 18:03 
GeneralRe: calling T's method from a generic class Pin
David A. Gray11-Sep-15 11:33
David A. Gray11-Sep-15 11:33 
QuestionHow to Insert Into WebServer Using WCF Pin
Käük Kwäý7-Sep-15 17:40
Käük Kwäý7-Sep-15 17:40 
AnswerRe: How to Insert Into WebServer Using WCF Pin
Eddy Vluggen7-Sep-15 23:58
professionalEddy Vluggen7-Sep-15 23:58 
QuestionFormatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 3:52
Ashfaque Hussain7-Sep-15 3:52 
AnswerRe: Formatting the RDL report tablix Pin
Afzaal Ahmad Zeeshan7-Sep-15 9:32
professionalAfzaal Ahmad Zeeshan7-Sep-15 9:32 
GeneralRe: Formatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 21:00
Ashfaque Hussain7-Sep-15 21:00 

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.