Search code examples
c#.netcastingoperators

The * operator must be applied to a pointer


Getting the error :

The * opertaor must be applied to a pointer

public static void SetClass(decimal Value, string input)
{
    Utils.SetMemory(Offsets.ClassName, new byte[16]);
    byte[] Multiplier = new byte[] { 0x04 };
    byte[] inputBytes = Encoding.ASCII.GetBytes(input);
    Utils.SetMemory(Offsets.ClassName + ((uint)Value - 1 + * 0x10), Utils.Multiply(inputBytes, Multiplier));
}

If I remove the "+" thats in front of the "*" It says

cannot convert from long to uint

So if converting it is the solution how would I do that?

Need This With Custom numericUpDown

Utils.SetMemory(Offsets.ClassName + ((uint)numericUpDown1.Value - 1) * 0x10, "Classes");

Want To Call Method Like

Stats.SetClass(numericUpDown Here.Value, text string here);

Im New To C#

Edit

public static void SetMemory(uint Offset, byte[] value)
{
    PS3.SetMemory(Offset, value);
}

Solution

  • look at this part (uint)Value - 1 + * 0x10. You are not following mathematical rules for adding and multiplication, + or * needs two operands. You are not supplying two operands. Here + * 0x10 there is two operator after each other and this cause a problem. If you want to add 0x10 to previous result remove * and if you want to multiply by 0x10 remove the +.

    The problem with cannot convert from long to uint. error is that maybe Offsets.ClassName variable is of type long or Int64, The result of Offsets.ClassName + ((uint)Value - 1 * 0x10) statement is long because the result of ((uint)Value - 1 * 0x10) is uint and when you have long + uint the result type would be long. Now you want to pass a long variable to a function which accepts uint and this cause error because there is no implicit conversion from long to uint.