Click here to Skip to main content
15,910,980 members
Home / Discussions / C#
   

C#

 
AnswerRe: Optimize this code Pin
Christian Graus5-Feb-09 20:41
protectorChristian Graus5-Feb-09 20:41 
AnswerRe: Optimize this code Pin
Vikram A Punathambekar5-Feb-09 21:27
Vikram A Punathambekar5-Feb-09 21:27 
AnswerRe: Optimize this code Pin
kaminem5-Feb-09 23:52
kaminem5-Feb-09 23:52 
AnswerRe: Optimize this code Pin
Daniel Grunwald6-Feb-09 1:37
Daniel Grunwald6-Feb-09 1:37 
AnswerRe: Optimize this code Pin
DaveyM696-Feb-09 2:17
professionalDaveyM696-Feb-09 2:17 
AnswerRe: Optimize this code Pin
Ben Fair6-Feb-09 2:46
Ben Fair6-Feb-09 2:46 
AnswerRe: Optimize this code Pin
Ennis Ray Lynch, Jr.6-Feb-09 2:54
Ennis Ray Lynch, Jr.6-Feb-09 2:54 
AnswerRe: Optimize this code [modified] Pin
DaveyM696-Feb-09 3:33
professionalDaveyM696-Feb-09 3:33 
Edited to get < and > to display!

This works - using an interface/generics.
public interface IMath<T>
{
    double CalculateDifference(T from, T to);
}
public class TestMath : IMath<int>, IMath<double>, IMath<datetime>
{
    #region IMath<int> Members

    public double CalculateDifference(int from, int to)
    {
        return to - from;
    }

    #endregion

    #region IMath<double> Members

    public double CalculateDifference(double from, double to)
    {
        return to - from;
    }

    #endregion

    #region IMath<datetime> Members

    public double CalculateDifference(DateTime from, DateTime to)
    {
        return (to - from).TotalSeconds;
    }

    #endregion
}
TestMath testMath = new TestMath();
Console.WriteLine(testMath.CalculateDifference(DateTime.Now, DateTime.Now.AddDays(1)));


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

modified on Friday, February 6, 2009 9:40 AM

QuestionCombobox Selection in Gridview for Windows Application Pin
pavanip5-Feb-09 19:57
pavanip5-Feb-09 19:57 
Questionhow to update two different tables of a datagrid using a single query Pin
jayamksriram5-Feb-09 19:22
jayamksriram5-Feb-09 19:22 
AnswerRe: how to update two different tables of a datagrid using a single query Pin
Vimalsoft(Pty) Ltd5-Feb-09 20:21
professionalVimalsoft(Pty) Ltd5-Feb-09 20:21 
AnswerRe: how to update two different tables of a datagrid using a single query Pin
tasumisra5-Feb-09 21:20
tasumisra5-Feb-09 21:20 
Questionsql error while running an exe of a c# windows application Pin
sandhya145-Feb-09 18:46
sandhya145-Feb-09 18:46 
AnswerRe: sql error while running an exe of a c# windows application Pin
Vimalsoft(Pty) Ltd5-Feb-09 20:29
professionalVimalsoft(Pty) Ltd5-Feb-09 20:29 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya145-Feb-09 22:25
sandhya145-Feb-09 22:25 
GeneralRe: sql error while running an exe of a c# windows application Pin
Vimalsoft(Pty) Ltd5-Feb-09 23:16
professionalVimalsoft(Pty) Ltd5-Feb-09 23:16 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya145-Feb-09 23:32
sandhya145-Feb-09 23:32 
GeneralRe: sql error while running an exe of a c# windows application Pin
Vimalsoft(Pty) Ltd5-Feb-09 23:37
professionalVimalsoft(Pty) Ltd5-Feb-09 23:37 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya145-Feb-09 23:46
sandhya145-Feb-09 23:46 
GeneralRe: sql error while running an exe of a c# windows application Pin
Vimalsoft(Pty) Ltd6-Feb-09 0:09
professionalVimalsoft(Pty) Ltd6-Feb-09 0:09 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya146-Feb-09 0:28
sandhya146-Feb-09 0:28 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya146-Feb-09 0:39
sandhya146-Feb-09 0:39 
GeneralRe: sql error while running an exe of a c# windows application Pin
sandhya146-Feb-09 19:45
sandhya146-Feb-09 19:45 
Questionhow to create sub tables in sql server Pin
praveenvkumarv5-Feb-09 18:02
praveenvkumarv5-Feb-09 18:02 
AnswerRe: how to create sub tables in sql server Pin
Christian Graus5-Feb-09 20:41
protectorChristian Graus5-Feb-09 20:41 

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.