dankmememachine
dankmememachine
CC#
Created by dankmememachine on 4/2/2023 in #help
✅ Math problem related to drawing a line renderer relative to an object in Unity
4 replies
CC#
Created by dankmememachine on 3/15/2023 in #help
❔ How would I call a method created as a top level statement outside of the initial file?
I have Program.cs with a method that is a static int,
static int Example()
static int Example()
and have tried to call it in a new file called Test.cs, by calling
Program.Example()
Program.Example()
but get the error: Cannot use local variable or local function declared in a top-level statement in this context
19 replies
CC#
Created by dankmememachine on 3/7/2023 in #help
❔ How to get specific fields from a Http GET request
I am working with a test API for learning purposes, I am using the following snippet to actually return the request body:
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Debug.Log(body);
}
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Debug.Log(body);
}
I get a response such as:
{"results":[{"code":"1002227_group_013","name":"Cargo Joggers","stock":{"stockLevel":1},"price":{"currencyIso":"USD","value":39.99,"priceType":"BUY","formattedValue":"$ 39.99","type":"WHITE"},"images":[{"url":"https://lp2.hm.com/hmgoepprod?set=source[/66/07/660740532368338c273791d92e308e445a5af9c5.jpg],origin[dam],category[],type[DESCRIPTIVESTILLLIFE],res[m],hmver[2]&call=url[file:/product/style]","baseUrl":"https://image.hm.com/assets/hm/66/07/660740532368338c273791d92e308e445a5af9c5.jpg"}],"categories":[],"pk":"9461964111873","sellingAttributes":["New Arrival"],"whitePrice":{"currencyIso":"USD","value":39.99,"priceType":"BUY","formattedValue":"$ 39.99","type":"WHITE"},"articles":[{"code":"1002227013","name":"Cargo
{"results":[{"code":"1002227_group_013","name":"Cargo Joggers","stock":{"stockLevel":1},"price":{"currencyIso":"USD","value":39.99,"priceType":"BUY","formattedValue":"$ 39.99","type":"WHITE"},"images":[{"url":"https://lp2.hm.com/hmgoepprod?set=source[/66/07/660740532368338c273791d92e308e445a5af9c5.jpg],origin[dam],category[],type[DESCRIPTIVESTILLLIFE],res[m],hmver[2]&call=url[file:/product/style]","baseUrl":"https://image.hm.com/assets/hm/66/07/660740532368338c273791d92e308e445a5af9c5.jpg"}],"categories":[],"pk":"9461964111873","sellingAttributes":["New Arrival"],"whitePrice":{"currencyIso":"USD","value":39.99,"priceType":"BUY","formattedValue":"$ 39.99","type":"WHITE"},"articles":[{"code":"1002227013","name":"Cargo
How could I go about getting a specific field from this output, such as the "name" or "images"?
208 replies
CC#
Created by dankmememachine on 1/12/2023 in #help
❔ How to format float to currency
I am multiplying small numbers (0.08 - 0.18 etc) and getting numbers like 34.44241. I want to figure out how I can multiply these values in terms of USD to be able to come out with a dollar and cent amount.
29 replies
CC#
Created by dankmememachine on 1/12/2023 in #help
❔ How to call a method that uses a struct in it's definition?
I program in C# with Unity most-often, I am branching out to 'normal' C# and am stuck on connecting a method to main in a practice project.
public struct sInformation
public struct sInformation
is used to define this method:
sInformation oIncome(int[] aoItemList, float[] aoItemCosts)
sInformation oIncome(int[] aoItemList, float[] aoItemCosts)
and I cannot find a way to run this in Main to actually begin working out the results. Any help would be greatly appreciated!
65 replies