私はこのジェネリックを指定しようとしましたが、私は複数のエラーを取得しています:場所を指定してジェネリックを指定するにはどうすればよいですか?
public void AddOrUpdate(T item, V repo) where T: IAuditableTable, V: IAzureTable<TableServiceEntity>
{
try
{
V.AddOrUpdate(item);
}
catch (Exception ex)
{
_ex.Errors.Add("", "Error when adding account");
throw _ex;
}
}
たとえば「:」最初の行にVがエラーを与えた直後に:
Error 3 ; expected
プラスその他のエラー:
Error 2 Constraints are not allowed on non-generic declarations
Error 6 Invalid token ')' in class, struct, or interface member declaration
Error 5 Invalid token '(' in class, struct, or interface member declaration
Error 7 A namespace cannot directly contain members such as fields or methods
Error 8 Type or namespace definition, or end-of-file expected
私の一般的なコーディングで明らかに間違っていますか?
更新:
私は変更を行い、コードは次のようになります。あなたがのために第二where
が必要
public void AddOrUpdate(Account account)
{
base.AddOrUpdate<Account, IAzureTable<Account>>(account, _accountRepository);
}
する必要がありますあなたは、おそらく 'スローする必要があります;'ここではなくスローEX 'より;'。それ以外の場合は、元のスタックトレースを送信します。 –