How do I mock the FileInfo information for a file?

I have a scenario in which I need much of the information from the FileInfo structure -- creation time, last write time, file size, etc. I need to be able to get this information cleanly, but also be ...

16 Oct at 19:42

Why are so many simple types in the .Net framework not marked as serializable?

I find it a recurring inconvenience that a lot of simple types in the .Net framework are not marked as serializable. For example: `System.Drawing.Point` or `Rectangle`. Both those structs only consis...

17 May at 14:17

How to initialize default value to C# out variables?

I used `TryParse` to parse a string to number. I need a solution to initialize out variable with default value, So when TryParse fails to convert I get my default value. Here is the code : Error > CS1...

6 May at 20:46

Asp.Net Core - simplest possible forms authentication

I have this old MVC5 application that uses forms authentication in the simplest possible form. There is only one account stored in web.config, there are no roles etc. ``` <authentication mode="Forms"...

How to Enter Placeholder Text Within Html.TextBoxFor in C# / MVC 4

Typically in HTML / CSS, if you want to add placeholder text to a textbox you would simply do this: `<input type="text" class="input-class" placeholder="Please enter your email"/>` But since I'm us...

17 May at 00:33

What's the purpose of EventArgs as base class in the event pattern?

The classic general C# event has these parameters: ``` (object sender, EventArgs e) ``` I can implement an event with a more specific signature for the `e` argument, deriving for `EventArgs`. Now,...

16 May at 21:56

How can I manually / programmatically create a DataRow?

My project's codebase has a legacy method that takes a DataRow as a parameter for which I would like to create a unit test method. How can I manually create a DataRow object to pass to the method? T...

16 May at 19:47

Using GraphServiceClient to get refresh tokens when authenticating using UserPasswordCredential in AuthenticationContext

Sincere apologies if I miss something from this post, as I'm at my wits end after reading around for hours. I'm attempting to write a back-end service (Windows) which will connect to the MS Graph API...

Convert ValueTuple to IEnumerable

Is there a saner way to do the following: ``` public static class ValueTupleAdditions { public static IEnumerable<object> ToEnumerable<A, B>(this ValueTuple<A, B> tuple) { yield return tuple.It...

16 May at 16:54

Using a custom argument validation helper breaks code analysis

I'd like to use a custom helper to simplify argument validation, something like this. ``` public static void ThrowIfNull(this object value, string parameterName) { if (value == null) { ...

Insert a list using dapper.NET C#

I'd like to insert a list of objects in an SQL table. I know this question [here](https://stackoverflow.com/questions/21209757/dapper-insert-a-list) but I don't understand. Here is my class : ``` p...

23 May at 11:55

DateTime validation not working despite a field with identical code working perfectly (in C# MVC, ASP.Net Core)

# Edit 1 Just to Clarify a couple of points, - - - --- I have my fingers crossed I'm missing something obvious because this makes no sense to me. Any help you can offer would be much appreciate...

C# ServiceStack.Redis store objects in hashmap

First, a link to the library: [ServiceStack.Redis](https://github.com/ServiceStack/ServiceStack.Redis) Now, I want to store objects of type `T` where T contains fields `Key` and `Value`. (for this ex...

Gradle - Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7)'

I am trying to import Gradle project in Intellij Idea with local Gradle distrib and getting stacktrace with the following message: `Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7...

16 May at 08:13

Could not load file or assembly Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.0.0

After update to the new package Microsoft.EntityFrameworkCore.SqlServer 1.1.2 I got error when try to create DBContext: > System.IO.FileLoadException occurred HResult=0x80131040 Message=Could no...

How do I Mimic Number.intBitsToFloat() in C#?

I have been going crazy trying to read a binary file that was written using a Java program (I am porting a Java library to C# and want to maintain compatibility with the Java version). # Java Library...

20 Jun at 09:12

How to get absolute path in ASP.Net Core alternative way for Server.MapPath

How to get absolute path in ASP net core alternative way for `Server.MapPath` I have tried to use `IHostingEnvironment` but it doesn't give proper result. ``` IHostingEnvironment env = new HostingEn...

ServiceStack Server-Side Events errors

Trying to deal with the problem but can't understand why out such errors. I get this error in cosole Google Chrome: EventSource's response has a MIME type ("text/html") that is not "text/event-stream...

17 May at 07:30

Confusion regarding threads and if asynchronous methods are truly asynchronous in C#

I was reading up on async/await and when `Task.Yield` might be useful and came across [this post.](https://stackoverflow.com/questions/22645024/when-would-i-use-task-yield) I had a question regarding...

23 May at 11:47

Hide scrollbar in FlatList (React Native) in Android

I am trying to use FlatList (React-native) in my app. I am using it horizontally and can see the scrollbar. There is an option in ScrollView to hide the scrollbar but not in FlatList. Has anyone been ...

23 May at 12:18

How to reload page the page with pagination in Angular 2?

How can I reload the current page on Angular 2? if iam in page 2 (pagination) and refresh the page it will show page 1(URL pageload) but i want i refresh the page 2 and it will appear in page 2

ASP .NET Core use multiple CORS policies

I am trying to setup 2 CORS policies. One as an api default and the other to use on `Controllers` as I need them. The reason I want to do this is because I have an endpoint that takes in an object w...

15 May at 18:25

Set global $PATH environment variable in VS Code

I'm defining a custom `$PATH` environment variable in my `~/.bash_profile` (on a Mac), like so: ``` PATH="$HOME/.cargo/bin:$PATH:$HOME/bin" ``` However, VS Code of course does not run my `.bash_pro...

15 May at 15:44

Remove Unnamed columns in pandas dataframe

I have a data file from columns A-G like below but when I am reading it with `pd.read_csv('data.csv')` it prints an extra `unnamed` column at the end for no reason. ``` colA ColB colC colD ...

15 May at 15:40

ImportError: No module named 'Cython'

I'm trying do `from Cython.Build import cythonize` and I get the message `ImportError: No module named 'Cython'`, but I installed the Cython with the comand `pip install Cython`. What's wrong? Python ...

24 Feb at 16:40