編譯器錯誤 CS0193
更新:2007 年 11 月
錯誤訊息
必須套用 * 或 -> 運算子至指標
* 或 -> 運算子與非指標型別 (Nonpointer Type) 搭配使用。如需詳細資訊,請參閱指標型別 (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);
}
}