Jibz
Jibz
CC#
Created by Jibz on 11/3/2023 in #help
❔ How do I check for an array key in Dictionary?
Dictionary<int[], int> test =
new()
{
{ new int[] { 2, 3 }, 3 }, // <- this one
{ new int[] { 3, 3 }, 6 },
{ new int[] { 3, 2 }, 3 }
};

Console.WriteLine(test.ContainsKey(new int[] { 2, 3 }));
Dictionary<int[], int> test =
new()
{
{ new int[] { 2, 3 }, 3 }, // <- this one
{ new int[] { 3, 3 }, 6 },
{ new int[] { 3, 2 }, 3 }
};

Console.WriteLine(test.ContainsKey(new int[] { 2, 3 }));
output:
False
14 replies
CC#
Created by Jibz on 9/25/2023 in #help
✅ How do I convert a char to ascii and ascii back to char?
I tried this:
int b = (int)'b';
int e = (int)'e';
int c = e - b;
Console.WriteLine("char is: " + c);
int b = (int)'b';
int e = (int)'e';
int c = e - b;
Console.WriteLine("char is: " + c);
and the output is:
char is:
basically .... nothing
26 replies
CC#
Created by Jibz on 8/15/2023 in #help
✅ cannot connect console dotnet project with microsoft SQL
I'm following this : https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-dotnet-core?view=azuresql-mi I'm running microsoft sql from docker. I can access my database from azure data studio by setting server as "localhost" so I tried to do the same in my code. My confusion is here builder.DataSource = "<your_server.database.windows.net>"; setting "server" in azure data studio works so I thought it should work as well in code but it throws error when I do this: builder.DataSource = "localhost"; or this builder.DataSource = "localhost.database.windows.net"; What am i doing wrong?
4 replies
CC#
Created by Jibz on 8/10/2023 in #help
❔ BinaryFormatter.Serialize(Stream, object)' is obsolete, What do I use instead?
I'm learning serialization in C# but it says binary formatters are obsolete. what should i use?
11 replies
CC#
Created by Jibz on 7/27/2023 in #help
getting warning: CS8618 - Non-nullable variable must contain a non-null value when exiting construct
I guess, it's not a big deal since the code is getting compiled but I still want to understand why I'm getting this warning and how can I resolve this. I was using a generic struct
truct Rectangle<T>
{
T length;
T width;

public T Length{
readonly get{ return length; }
set{ length = value; }
}
public T Width{
readonly get{ return width; }
set{ width = value; }
}

public Rectangle(T L, T W) // <-- this is where I am getting the warning
{
Length = L;
Width = W;
}
}
truct Rectangle<T>
{
T length;
T width;

public T Length{
readonly get{ return length; }
set{ length = value; }
}
public T Width{
readonly get{ return width; }
set{ width = value; }
}

public Rectangle(T L, T W) // <-- this is where I am getting the warning
{
Length = L;
Width = W;
}
}
45 replies