N
nicol
hi;
this program has two error if u can help me;
Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)
//*********************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication93
{
class Program
{
static void Main(string[] args)
{
sum (12.509, 49.4);
}
public double sum (T a, T b) // place 0f this error
{
if (typeof(T) == typeof(int))
{
return (double)(Convert.ToInt32(a) +
Convert.ToInt32(b));
}
if (typeof(T) == typeof(double))
{
return Convert.ToDouble(a) + Convert.ToDouble(b);
}
if (typeof(T) == typeof(byte))
{
return (double)(Convert.ToByte(a) +
Convert.ToByte(b));
}
return 0;
}
}
}
this program has two error if u can help me;
Error 1 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'T' could not be found (are you
missing a using directive or an assembly reference?)
//*********************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication93
{
class Program
{
static void Main(string[] args)
{
sum (12.509, 49.4);
}
public double sum (T a, T b) // place 0f this error
{
if (typeof(T) == typeof(int))
{
return (double)(Convert.ToInt32(a) +
Convert.ToInt32(b));
}
if (typeof(T) == typeof(double))
{
return Convert.ToDouble(a) + Convert.ToDouble(b);
}
if (typeof(T) == typeof(byte))
{
return (double)(Convert.ToByte(a) +
Convert.ToByte(b));
}
return 0;
}
}
}