C
C#9mo ago
Fluffy

I ethically borrowed some source code and it doesn't work

I took some source code but when I pasted it, it started blaring errors and I'm not too sure what the errors mean.
10 Replies
Fluffy
Fluffy9mo ago
It's in Unity
Fluffy
Fluffy9mo ago
The original function was this:
public static float Min(params float[] values)
{
int num = values.Length;
if (num == 0)
{
return 0f;
}

float num2 = values[0];
for (int i = 1; i < num; i++)
{
if (values[i] < num2)
{
num2 = values[i];
}
}

return num2;
}
public static float Min(params float[] values)
{
int num = values.Length;
if (num == 0)
{
return 0f;
}

float num2 = values[0];
for (int i = 1; i < num; i++)
{
if (values[i] < num2)
{
num2 = values[i];
}
}

return num2;
}
Pobiega
Pobiega9mo ago
look at the error messages you are getting
Angius
Angius9mo ago
Well, what are the errors?
Fluffy
Fluffy9mo ago
Im trying to get them but my screenshot program is breaking on me
Pobiega
Pobiega9mo ago
you can read them yourself, thats fine
Fluffy
Fluffy9mo ago
Top Level statements must precede namespace and type declarations
Pobiega
Pobiega9mo ago
you can't just randomly paste code anywhere in a file and expect it to work Im guessing you pasted this outside a class
Fluffy
Fluffy9mo ago
ah shoot I think i did Yeah that was a dumb mistake It really looked like it was in the class Ty for the help
Angius
Angius9mo ago
Code goes into methods, methods into classes, classes into namespaces Yeah