私は C# が初めてで、あまり詳しくありません。との違いに戸惑っていますがnew PostpaidProfile();
、default(AutoliftResult);
私が言いたいのは、それらの呼び方の違いです。以下は、私が何と呼んでいるかもわからないクラスまたはオブジェクトです
public class PostpaidProfile
{
public bool WasRetrieved { get; set; }
public string AccountCategory { get; set; }
public string AccountNum { get; set; }
public string Acd { get; set; }
public string ActivationDate { get; set; }
public int? AgingDays { get; set; }
public decimal? CreditRating { get; set; }
public string CutOff { get; set; }
public string Cycle { get; set; }
public bool? IsBlacklisted { get; set; }
public bool? IsNopsa { get; set; }
public decimal? Msf { get; set; }
public string RatePlan { get; set; }
public string ServiceStatus { get; set; }
public int? VipCode { get; set; }
public string Zip { get; set; }
public string Remarks { get; set; }
}
public class AutoliftResult
{
public bool IsSuccess { get; set; }
public decimal StatusCode { get; set; }
public string Message { get; set; }
public string SRNumber { get; set; }
}
そしてここでそれらがどのように呼び出されるか
PostpaidProfile output = new PostpaidProfile();
AutoliftResult output = default(AutoliftResult);
私の質問は、それらの違いは何ですか? (私は彼らの内容について話しているのではありません)私が宣言しても同じですかAutoliftResult output = new AutoliftResult();
new PostpaidProfile()
クラスの新しいインスタンスを作成します。
default(AutoliftResult)
指定されたタイプのデフォルト値を作成します。参照型の場合はnull
です。値型の場合、それは通常0
、その型に変換されるint
ものです0
。つまり、型が の場合、デフォルト値はです。タイプが の場合bool
、デフォルト値はfalse
などです。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加