using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TwoTuple<Boolean, Double> two = new TwoTuple<Boolean, Double>(true, 56.00);
Boolean bo = two.first;
Double st = two.second;
Console.WriteLine(bo+st);
Console.Read();
}
}
public class TwoTuple<A,B> {
public const A first=null;
public const B second=null;
public TwoTuple(A a,B b){
first=a;
second=b;
}
public String toString(){
return ")"+first+", " +second+")";
}
}
}
public const A first = null;
public const B second = null;
This is because the two types of error does not recognize it ?
------ Solution ------------------------------------ --------
------ Solution ---------------------------------------- ----
that mistake compile it ? For C do not understand !
------ Solution ---------------------------------------- ----
public A first = default(A);
public B second = default(B);
------ Solution ------------------------------ --------------
sixth floor is that you type is not clear , there may be a value type will not be null
------ Solution --------------------------------------------
public readonly A first;
public readonly B second;
------ Solution ---------------------------- ----------------
compiled tips have been very clear:
Null can not be converted to a type parameter "A", as it may be not be a null value type. Please consider using the "default (A)".
------ For reference only -------------------------------------- -
pursuing big god answers
------ For reference only ------------------------------- --------
did not help me answer the next Mody. . .
------ For reference only -------------------------------------- -
own Dinga . . . . . . . . . . . . . . .
没有评论:
发表评论