frankcollins3 / ASPokedex

Pokedex with ASP backend / razor pages, and VanillaJS front end
1 stars 0 forks source link

👎 too many character Literals when trying index & dot notation together [10:08am] #22

Closed frankcollins3 closed 11 months ago

frankcollins3 commented 11 months ago

attempting to do: Screen Shot 2023-09-25 at 10 06 48 AM Screen Shot 2023-09-25 at 10 06 05 AM 👍 data2.sprites.front_default 👍 data2["sprites"]["front_default"].ToString(); 👍 data2.types[0].type.name 👎 data2["types"][0]["type"]["name"].ToString();

error: this line of code in Index.cshtml.cs causes the error: Screen Shot 2023-09-25 at 10 06 10 AM

error CS1012: Too many characters in character literal [/Users/chasethrillz/Desktop/aspokedex/aspokedex.csproj] proposed approach: in .net it seems dot notation, in the context of a foreach loop within a code-behind file, is done like this: JS: data2.sprites.front_default

frankcollins3 commented 11 months ago

👍 string pokemonType = data2["types"]?[0]?["type"]?["name"]?.ToString(); [11:00am]

frankcollins3 commented 11 months ago

Screen Shot 2023-09-25 at 11 21 28 AM Screen Shot 2023-09-25 at 11 21 18 AM

👍{pokemonType} right here works when concatenated Console.Write("pokemonType: \t" + pokemonType + " empty \n");
iterm2 logs: pokemonType: grass empty

👎 {pokemonType} the logging of same above variable that works when concatenated did not work without .concat() Console.WriteLine("type: \t", pokemonType);

iterm2 logs: type: [11:25am]

frankcollins3 commented 11 months ago

adding % to the string makes it work Screen Shot 2023-09-25 at 11 27 58 AM Screen Shot 2023-09-25 at 11 28 13 AM

frankcollins3 commented 11 months ago

part of that above problem is trying to use the arguments how JS uses console.log() this created the need for format strings