✅ Q about the "?" symbol when declaring vars
Hello everybody ,I have seen some c# vidoes where people declare variables with "?", for example "int?","bool?" , I have asked copilot what does it mean and he said that its just "normal variables" but they are special in that they can also store Null .
my question is : how accurate is his answer and in what case/context will I use :"type?" instead of "type"
thanks...
✅ Covariant return type properties
Am I missing something - I thought that property return types could be covariant if they were readonly. So why does this not compile?
```cs
public abstract class C
{...
How do I reference either the x or y field of a Vector2 depending on some condition?
Hello. I'm resizing a grid, to do so I use two functions, the first resizes the grid in the X axis, the second on the Y axis. I would like to merge them but I have difficulties coming up with a solution.
My main issue is that I would need to have some way to tell the method to either use (and update, very important) the x or y field of a Vector2 depending on some boolean (if changeXAxis = true then use coordinates.x else use coordinates.y, if it makes sense).
I have tried multiple things, for example setting variables with a ternary operator like so:...
✅ AddHttpClient and AddHostedService
I have a hosted service that I register with my DI as so
serviceCollection.AddHostedService<ExampleService>()
and everything works fine. However I now need this service to use it's own HttpClient
. That seemed like no issue, Just add serviceCollection.AddHttpClient<ExampleService>(x => x.Timeout = Timeout.InfiniteTimeSpan)
and I should be good to go, or so I thought..
Everything resolved correctly and the program ran, except for the fact that the injected HttpClient
did not in fact have infinite timeout. A quick breakpoint check later and i find that the configuration action isn't triggering, or from what I found online, that client isn't used at all and it's instead falling back to the standard HttpClient
that AddHttpClient
adds for everything that isn't the targeted type....✅ Obfuscate
How do I assign an OBF to an application I made in C#? When I used ConfuserEx, I couldn't assign an OBF because I was using Guna2. Is there another application?
Testing multi layered .NET application
Hey, I'm new to C#/.NET and i'm currently making my first project.
This project has a Controller - Service - Repository structure.
Right now I'm trying to write tests for my controllers but I'm facing a problem trying to mock my service.
In the setup of my mock, i pass the data it should return, but the result is null (without the returned data)
...
How do I run/start my code?
I've practically only ever used Python, so I'm unsure how to run this code on Visual Studio Code?
Sorry if this is really basic, I just genuinely am so stressed because I need to get this done asap (rocky) and I'm just a bit stuck right now 😭...
Costom ScrollViewer Wpf
I have made a slider that looks like the image below but I want to know if it’s possible to make the exact same thing but vertical and a ScrollViewer instead of a slider. I have tried a lot but not succeeded. Need it for a Listbox. I like that design a lot
✅ ObservableCollection.Add() takes too long.
As the title and the image pretty much have explained it, ObservableCollection takes 4 second just to add a record, is there anyone also has this problem, may I ask for some suggestion ?
Default value to textarea in .net core MVC
<textarea asp-for="Description" class="form-control">@ViewBag.Product.Description</textarea>
<textarea asp-for="Description" class="form-control">@ViewBag.Product.Description</textarea>
Help on how async/await works
Hi everyone, I am currently learning about asynchronous programming in c# and have been reading the documentation at https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/. I understand how the usage of await will pause execution until the task completes, but I dont fully understand where execution goes after hitting an await statement. The documentation mentions `The await keyword is where the magic happens. It yields control to the caller of the method that performed await,...
Help about UI design for a code editor
Hi everyone, i am making a code editor but i want to enhance my design because it looks old. I need some help. Thanks !
✅ using using to clear up ambiguous references.
I've to two method called index:
Microsoft.EntityFrameworkCore.Index
System.ComponentModel.DataAnnotations.Schema.Index
i don't use the 2nd one. I want every mention of index to be interpreted as the first one....Class with same name as namespace
In the same app still (Ilanos), in my
Ilanos.Application
proj I have a lot of classes that are supposed to use the Joke
class.
However, for the sake of organization, I'm separating them like this: ```
|- Ilanos.Application
|- Mappers
|- Joke...Unable to create DbContext
I'm trying to create by db tables right now, still in the start of a project.
I have a
ApplicationDbContext
in my Infrastructure project and I'm running dotnet ef migrations Initial
, that's all.
Project is public for now, could be seen here (yes, I know it's messy, I don't like clean architecture, I mostly don't know how to do it, not my style of coding)
...Access database field in one to many relationship in asp net core
In my example I have Polls and PollOptions tables, I can access PollOptions.Poll table but not the other way around
Caching?
I have been meaning to ask a question about caching. How do you determine what data to cache and when?
Trying to scaffold a MySQL database with Rider
I am trying to scaffold a MySQL database. I am using Rider. I found this article on the MySQL website:
https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core-scaffold-example.html
but the commands it uses seems to require Visual Studio which i am not using.
...