Ice_trooper
Ice_trooper
CC#
Created by Ice_trooper on 6/10/2024 in #help
Why can't I install this NuGet package
No description
32 replies
CC#
Created by Ice_trooper on 1/24/2023 in #help
❔ Return IEnumerable backwards
44 replies
CC#
Created by Ice_trooper on 1/23/2023 in #help
❔ Regex to find string between _ or next uppercase letter
Can you help me with regex?
Roads_RoadNode
Roads_Road_261Node
Roads_Curb_91Node
Roads_CurbNode
Roads_Marking_123Node
Roads_MarkingNode
Roads_RoadNode
Roads_Road_261Node
Roads_Curb_91Node
Roads_CurbNode
Roads_Marking_123Node
Roads_MarkingNode
I need to capture these:
Road
Road
Curb
Curb
Marking
Marking
Road
Road
Curb
Curb
Marking
Marking
This regex works only for strings between underscore, but I need to support also other cases. Roads_(.*)_.* Don't have any idea how to fix it. :/
7 replies
CC#
Created by Ice_trooper on 1/19/2023 in #help
❔ Handling different version changes for external standard.
9 replies
CC#
Created by Ice_trooper on 1/17/2023 in #help
❔ XML serialization - internal XML element
9 replies
CC#
Created by Ice_trooper on 12/12/2022 in #help
✅ Explicit call ToString() when interpolating on primitive (value) types
Is it necessary to call ToString() when interpolating string using primitive (int, float, etc.) or in general value types? Would it avoid boxing allocation? Example:
int someInt = 4;
MyStructWithImplementedInterfaceIFormatable myStruct;
Console.Write($"My number is: {someInt.ToString()} and struct: {myStruct.ToString()}");
int someInt = 4;
MyStructWithImplementedInterfaceIFormatable myStruct;
Console.Write($"My number is: {someInt.ToString()} and struct: {myStruct.ToString()}");
26 replies
CC#
Created by Ice_trooper on 11/26/2022 in #help
❔ How to force method call regardless of type?
public class TempBaseClass
{ }

public class TempGenericClass<T> : TempBaseClass
{
public event Action<T> someEvent;

public void Register(Action<T> action)
{
someEvent += action;
}
}

public class StringTempClass : TempGenericClass<string>
{ }

public class IntegerTempClass : TempGenericClass<int>
{ }

public class ClientClass
{
// What if this will be IntegerTempClass? Would Method2 be called or none?
public TempBaseClass someBaseClass;

public void Foo()
{
if (someBaseClass is StringTempClass stringTempClass)
{
stringTempClass.Register(Method1);
}
else if (someBaseClass is TempGenericClass<object> objectTempClass)
{
objectTempClass.Register(Method2);
}
}

public void Method1(string text)
{
Debug.Log(text);
}

public void Method2(object obj)
{
Debug.Log(obj.ToString());
}
}
public class TempBaseClass
{ }

public class TempGenericClass<T> : TempBaseClass
{
public event Action<T> someEvent;

public void Register(Action<T> action)
{
someEvent += action;
}
}

public class StringTempClass : TempGenericClass<string>
{ }

public class IntegerTempClass : TempGenericClass<int>
{ }

public class ClientClass
{
// What if this will be IntegerTempClass? Would Method2 be called or none?
public TempBaseClass someBaseClass;

public void Foo()
{
if (someBaseClass is StringTempClass stringTempClass)
{
stringTempClass.Register(Method1);
}
else if (someBaseClass is TempGenericClass<object> objectTempClass)
{
objectTempClass.Register(Method2);
}
}

public void Method1(string text)
{
Debug.Log(text);
}

public void Method2(object obj)
{
Debug.Log(obj.ToString());
}
}
28 replies
CC#
Created by Ice_trooper on 10/30/2022 in #help
Convert code to utility or extension method
7 replies