Kru
Kru
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
well, if you ever need Random baby name maker, you know where to look :), Thanks again!
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
Got you,
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
I assumed json input would magically conver it as string[]
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
oh yeah, as I used string[] firstName = [ "Foo", "Bar", "Foo2", "Bar2" ]; at the top. using external file, I had to use the same logic just data input as json instead of manual.
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
Ok, that make sense as well.
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
Thanks for your patience and not providing the actual solution. I never thought I would actually use var at all.
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
Fixed it, I had to re-read your above statement. This solved it. string jsonfile = File.ReadAllText(@"C:\Users\Home\Documents\CSharp\HelloWorld\RandomName\CombineFirstNameDb.json"); var sample = JsonSerializer.Deserialize<string[]>(jsonfile); Console.WriteLine(sample[0]);
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
baby steps... I changed it to use this string jsonfile = File.ReadAllText(@"C:\Users\Home\Documents\CSharp\HelloWorld\RandomName\CombineFirstNameDb.json"); string sample = JsonSerializer.Deserialize<string>(jsonfile); Console.WriteLine(sample[0]); Getting error below. I did confirm no error on json file that's loaded in VS and online as well. System.Text.Json.JsonException: 'The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1.' InvalidOperationException: Cannot get the value of a token type 'StartArray' as a string.
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
ahh got it, I was trying to skip over a step. Let me do the same using what I had before.
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
error i am getting is, `System.Text.Json.JsonException HResult=0x80131500 Message='C' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. Source=System.Text.Json
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
string sample2 = JsonSerializer.Deserialize<string>("C:\\Users\\Home\\Documents\\CSharp\\HelloWorld\\RandomName\\CombineFirstNameDb.json"); Console.WriteLine(sample2[10]);
31 replies
CC#
Created by Kru on 12/26/2023 in #help
Random Name generator.
I was able to get an error to come up this time, looks like some syntex issue? This is the new code
31 replies
CC#
Created by Kru on 12/18/2023 in #help
Block of code
oh wow, this blew up. I did some digging around and found out that, VS Studio does not return the {} in the code block. See below. There are short cut you can use but no easy way to do it, unless you do the whole code block using TAB, TAB. https://www.youtube.com/watch?v=1hmF00u2uF4
33 replies
CC#
Created by Kru on 12/18/2023 in #help
Block of code
Understood,
33 replies
CC#
Created by Kru on 12/18/2023 in #help
Block of code
is that specific shortcut?
33 replies