89 questions
1
vote
1
answer
143
views
In C# 7.3, is it possible to write a method parameter attribute that modifies the argument, prior to the method body execution?
I found that I am regularly Trim()-ing whitespace from string values passed into my functions. This usually looks like:
public void MyFunction(string param) {
if (param != null) { // Null check is ...
1
vote
1
answer
665
views
Check not null and greater than with c# 7.3 using "is" operator
In latest version of c# you can check not null with is not.
I am using 7.3 version, How can I use is operator to check not null
1
vote
1
answer
54
views
why approval index action not redirect to pending action view although no error on debug code?
I work on an ASP.NET MVC project. I face issue action ApprovalIndex is not redirecting to action PendingManagersRequests although no error happens.
I debug and trace breakpoint until reach action ...
0
votes
2
answers
140
views
UIElement Reference
I'm currently rewriting a Joystick Usercontrol from the old typical codebehind usercontrol into a MVPVM WinUI 3 and having a problem referencing a UIElement from the presenter class. Yes I know you ...
4
votes
1
answer
3k
views
Why does adding <LangVersion>default</LangVersion> to a .csproj file fix a C# language version error?
I was using the "or pattern" in my C# code, but I am getting the following error:
CS8370 Feature 'or pattern' is not available in C# 7.3. Please use
language version 9.0 or greater.
I ...
0
votes
1
answer
890
views
Could not resolve type with token 01000012 (expected class ... in assembly ...)
I have a C# project in Godot that I've just updated from C# 7 to C# 10 and .NET 6.
Everything works fine and I get no errors in VS code but when I try to build the project from the
Godot game engine I ...
0
votes
2
answers
65
views
is there a way to have line amount higher than 6, when my array bound is set to 6?
I would like to print out more than six lines of six random numbers, but array bound is blocking me. I have set my array 'numbers' to six in order to always get just six random numbers, but now I dont ...
0
votes
0
answers
448
views
Xamarin.iOS CS8370 Feature 'range operator' is not available in C# 7.3. Please use language version 8.0 or greater
I'm trying to follow one of the tutorial for Xamarin application.
My VS is:
Microsoft Visual Studio Community 2019
Version 16.11.5
VisualStudio.16.Release/16.11.5+31729.503
Microsoft .NET Framework
...
2
votes
1
answer
738
views
Using static statement not working in C# 7.3 on Dotnet framework 4.72
I'm converting an old application over from VB.Net to C# and got most of the converting done, but ran into an error message that should not be there (can't use "using static ..." in a couple ...
0
votes
1
answer
143
views
Type cast an generic enum T to its type of T
I am building an generic SelectListItem to be used with a dropdown. Trying to cast an Enum of type T to its type , but Iam missing something. LocalizedStringKeyFor complains that its getting two ...
6
votes
1
answer
7k
views
How do I properly use C# 8 with .NET 4.0
So I'm trying to utilize C# 8 in my .NET 4 web application by adding two entries in my .csproj file right inside the PropertyGroup node.
<LangVersion>8.0</LangVersion>
<Nullable>...
3
votes
3
answers
821
views
Convert decimal? to decimal in earlier versions of .NET (C# Version 7.3)
So after searching for similar questions, I haven't seen any results.
The error that keeps popping up is
Feature 'target-typed conditional expression' is not available in C# 7.3. Please use language ...
1
vote
1
answer
1k
views
Improving performance converting bytes into UInt32
I'm working on source code which processes 2GB of data which represents 60 seconds of network traffic. The total processing time is around 40 seconds. I'm trying to optimize my code for performance as ...
1
vote
0
answers
1k
views
How to make a WinForms Control transparent?
I would like to make an entire Control and its children have a see-through effect so that it looks disabled.
My Control was initially a UserControl but trying to change the alpha on the BackColor ...
0
votes
3
answers
1k
views
setting values of the model from a model
I have 3 models
1st Model
public class BlogPosts
{
public int BlogID { get; set; }
public int UserID { get; set; }
public string PostTitle { get; set; }
[AllowHtml]
...
0
votes
0
answers
63
views
Is there an attribute or compiler flag to remove the need to specify type constraints on extension methods of generic interfaces?
I have an interface like this:
public interface SomeInterface<A, B, C>
where A : SomeAClass, SomeAClass2
where B : SomeBClass
where C : SomeCClass, SomeBClass, EtcClass
{
A ObjA { get; }
B ...
0
votes
1
answer
955
views
Cast Enum to return Generic C# 7.3
More than probably this is a conceptual misunderstood but I want to know why.
I've a static method that can return one generic value T, and it also receives a string.
public static T GetWordType<...
0
votes
0
answers
83
views
C# Nested Custom Config: Alternative element types in element collections
Sorry, I am new to config files and xml.
This examples is close to what I want:
Correct implementation of a custom config section with nested collections? (state-county-example). Unfortunatelly code ...
0
votes
0
answers
215
views
How do I use Func<T, TResult> for a method with in parameters?
I'm trying to declare a Func<T, TResult> for a static method on a struct that has in parameters.
The signature of my method is something like this:
public static MyStruct MyMethod(in MyStruct ...
0
votes
1
answer
319
views
Why there's no Nullable-Generic Methods? which accept both references and value types
This Works
public static T? Read<T>(object value) where T : struct
{
return (T)Convert.ChangeType(value, typeof(T));
}
But this doesn't work:
Error CS8370 Feature '...
2
votes
1
answer
190
views
Is there a difference between !(x is null) and x is object
Is there a difference between !(x is null) and x is object?
Are there cases where they will return different results?
0
votes
0
answers
257
views
Common Methods for Repository Pattern w/ Unit of Work
I have a project where I am attempting to use Unit of Work w/ Repository design pattern for performing CRUD operations using EF Core. FWIW, I am on .NET Core 2.2.
Question:
Is there a way for me to ...
0
votes
1
answer
453
views
When I upload pdf document on Server. it,s save pdf but pdf size is 0 byte
i have to upload pdf on server on his particular folder. but tried upload code as below. after pdf save and load on my site it's show "Failed to load PDF document."
i check uploaded pdf on server it,...
0
votes
0
answers
398
views
How can I marshal a pointer to an array of structures as an array if the size of the array is contained in one of the structure fields?
I want to transfer one of the structures from the DXGI library, but I ran into a problem. The target structure contains a pointer to an array of structures, in the second after, where the first ...
7
votes
1
answer
6k
views
Deconstruct with List<T>
Is there a way to allow a list of tuples to deconstruct to a List<T>?
I get the following compile error with the following code sample:
Cannot implicitly convert type 'System.Collections....