Posted in
Sword Fighting Roblox Game Free To Copy
4 years ago
Type t = typeof(string); Debug.WriteLine(t.Name);This prints out "String". When you get the value of the property Name when t is assigned to a generic type...
Type t = typeof(List<string>); Debug.WriteLine(t.Name);
public static string GetFriendlyName(this Type type)
{
if (type.IsGenericType)
{
StringBuilder sb = new StringBuilder();
sb.Append(type.Name.Remove(type.Name.IndexOf('`')));
sb.Append("<");
Type[] arguments = type.GetGenericArguments();
for(int i = 0; i < arguments.Length; i++)
{
sb.Append(arguments[i].GetFriendlyName());
if (i + 1 < arguments.Length)
{
sb.Append(", ");
}
}
sb.Append(">");
return sb.ToString();
}
else
{
return type.Name;
}
}
Type t = typeof(List<String>); Debug.WriteLine(t.GetFriendlyName());This prints out "List<String>"
public bool Intersects(Polygon other)
{
foreach (Vector2 point in other.points)
{
if(PointInPolygon(point))
return true;
}
return false;
}
if (puckBounds.Intersects(goalBounds))
{
// Make puck bounce here
}
public static void Compile(String Output, String code)
{
CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters parameters = new CompilerParameters();
//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, code);
if (results.Errors.Count > 0)
{
foreach (CompilerError CompErr in results.Errors)
{
Debug.WriteLine(
"Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine);
}
}
else
{
Debug.WriteLine("Success!");
}
}using System.CodeDom.Compiler; using System.Diagnostics;

