Ben C# 'da yeni ve şablonları kullanan bir sınıf oluşturmaya çalışıyorum, argümanlarından biri için genel bir tür.Genel türünü kullanma 'Durum <T>' 1 türü bağımsız değişkenler gerektirir C#
class State<T>
{
private T state; // the state represented by a string
private double cost; // cost to reach this state (set by a setter)
private State cameFrom; // the state we came from to this state
aşağıdaki hatayı alıyorum: Bu Action delegate in .NET2 - Using the generic type 'System.Action<T>' requires '1' type arguments buldum
Using the generic type 'State<T>' requires 1 type arguments
ama ben herhangi bir kod eklememiş C# yeniyim beri benim durumda .. değil düzenli c-keskin kütüphaneler.
YARDIM.
private State cameFrom;
Seni 'özel DevletYorumunuz "bir dize ile temsil devlet" okur, ancak bu 'anlaşılacağı Durum '' string' türünde olmalıdır, bu noktada sadece sınıfı jenerik yapamazsınız. Aslında nasıl T 'kullanıyorsun? Sınıfınız için ne anlama geliyor? Bu anlama bağlı olarak, @ Valentin'in yorumu * uygun bir düzeltme olabilir, ancak diğer olası anlamlar için tamamen yanlış olabilir. – hvd