コンパイラ エラー CS0193
更新 : 2007 年 11 月
エラー メッセージ
* または -> 演算子はポインタに対して使用してください。
* 演算子または -> 演算子が、ポインタ以外の型と一緒に使用されました。詳細については、「ポインタ型 (C# プログラミング ガイド)」を参照してください。
次の例では CS0193 エラーが生成されます。
// CS0193.cs
using System;
public struct Age
{
public int AgeYears;
public int AgeMonths;
public int AgeDays;
}
public class MyClass
{
public static void SetAge(ref Age anAge, int years, int months, int days)
{
anAge->Months = 3; // CS0193, anAge is not a pointer
// try the following line instead
// anAge.AgeMonths = 3;
}
public static void Main()
{
Age MyAge = new Age();
Console.WriteLine(MyAge.AgeMonths);
SetAge(ref MyAge, 22, 4, 15);
Console.WriteLine(MyAge.AgeMonths);
}
}