Compiler Error CS0193
The * or -> operator must be applied to a pointer
The * or -> operator was used with a nonpointer type. For more information, see Pointer types.
The following sample generates CS0193:
C#
// 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);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: