Dultus
Dultus
CC#
Created by Dultus on 10/5/2023 in #help
❔ The best way to create custom types?
True, at this point..
15 replies
CC#
Created by Dultus on 10/5/2023 in #help
❔ The best way to create custom types?
public struct Id
{
private readonly int value;
public static Id FromInt(int value)=> new Id(value);
public Id(int value) => this.value = value;
public int GetInt() => this.value;
}
public struct Id
{
private readonly int value;
public static Id FromInt(int value)=> new Id(value);
public Id(int value) => this.value = value;
public int GetInt() => this.value;
}
So I guess something like this would be the best way still?
15 replies
CC#
Created by Dultus on 10/5/2023 in #help
❔ The best way to create custom types?
That's a good point.
15 replies
CC#
Created by Dultus on 5/16/2023 in #help
❔ Best way to wait for a certain time?
I'll try out Coravel, thanks! I'd usually go for a scheduler but that doesn't really fit the application.
5 replies
CC#
Created by Ben_T on 4/7/2023 in #help
❔ Accessing variable from another class
It really depends on where you want to call it. This way with your new method you just created a new customer.
21 replies
CC#
Created by Ben_T on 4/7/2023 in #help
❔ Accessing variable from another class
When you do so of course you're just getting 0.
21 replies
CC#
Created by Ben_T on 4/7/2023 in #help
❔ Accessing variable from another class
You still create new instances of the class you're trying to access.
21 replies
CC#
Created by Ben_T on 4/7/2023 in #help
❔ Accessing variable from another class
Yeah, that was missing information. A trmporary customer class would be the best option then imo. So a select method that writes the customer into a class variable or a static variable which you then access.
21 replies
CC#
Created by Ben_T on 4/7/2023 in #help
❔ Accessing variable from another class
Yes, that's correct. As you pointed out you're trying to access an empty instance. If you're planning to do a list of customers, I'd introduce an Id to them and a list of customers. You can create the list for the entire class or as a static object so you can access it from anywhere. Next, pick your customer from the list and then check the balance. An option could be to make a temporary variable like selectedCustomer that you set the selected customer to so you don't have to constantly access the list and search for it.
21 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Get full namespace name
Thanks tho!
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Get full namespace name
Yeah, a couple. But I'd prefer a version in which I don't take any class of a namespace. ^^
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Get full namespace name
Yes, but typeof requires a class. I can't pass in a Namespace name.
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Generalise Attributes?
Yeah, that works for me. That just explained why I didn't know of it. 😄
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Generalise Attributes?
Ah, I see. That's why I didn't know about it. Generic Attributes aren't a thing yet in .NET 6.0
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Generalise Attributes?
Ah, right. Generics. I'm dumb lol Thank you
11 replies
CC#
Created by Dultus on 3/29/2023 in #help
❔ Magnetic Links for application?
Ah, I see! Thank you, that makes my search easier. 🙂
5 replies
CC#
Created by Dultus on 2/10/2023 in #help
❔ Can't use ToastContentBuilder.Show();
5 replies
CC#
Created by Dultus on 1/24/2023 in #help
❔ Is there a way to remove brackets from empty methods?
Yeah, figured as much. Though CodeRush automatically "fixes" that and puts them in two new lines. x)
25 replies
CC#
Created by Dultus on 1/24/2023 in #help
❔ Is there a way to remove brackets from empty methods?
To save two lines for every 'empty' method that I don't need.
25 replies
CC#
Created by Dultus on 1/24/2023 in #help
❔ Can I generalise this method?
public static IEnumerable<Enum> TransformIdToEnums(string value, params Type[] enums)
{
string[] values = value.Split(',');
if (values.Length != enums.Length)
{
throw new MismatchedEnumLengthsException();
}
for (int i = 0; i < enums.Length; i++)
{
yield return (Enum)Enum.Parse(enums[i], value);
}
}
public static IEnumerable<Enum> TransformIdToEnums(string value, params Type[] enums)
{
string[] values = value.Split(',');
if (values.Length != enums.Length)
{
throw new MismatchedEnumLengthsException();
}
for (int i = 0; i < enums.Length; i++)
{
yield return (Enum)Enum.Parse(enums[i], value);
}
}
9 replies