10,267 questions with C#-related tags

Sort by: Updated
1 answer One of the answers was accepted by the question author.

.net 5.0 seems to be wrong in detecting zero-terminzted string

The following code: class Program { static void Main(string[] args) { const string s = "abc"; const string sz = "abc\0"; void Report(string str) =>…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,121 questions
asked 2020-12-09T17:09:31.873+00:00
Anatoli Koutsevol 21 Reputation points
accepted 2020-12-09T22:58:43.48+00:00
Anatoli Koutsevol 21 Reputation points
1 answer One of the answers was accepted by the question author.

There's a problem with this formula with Excel Scenarios in C#

I am using Microsoft.Interop.Excel to collect summaries from different scenarios in a specific worksheet. C# Code: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; …

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T10:45:10.4+00:00
kamalasubha muthukumar 41 Reputation points
accepted 2020-12-09T16:55:56.473+00:00
kamalasubha muthukumar 41 Reputation points
1 answer One of the answers was accepted by the question author.

method takes any enum

hi how to get this functionality: public static void GetEnum(string txt, out Enum result) { Enum.TryParse<value.GetType()>(txt, out value); // error } thanks in advance

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-09T09:35:15+00:00
essamce 621 Reputation points
accepted 2020-12-09T12:21:54.133+00:00
essamce 621 Reputation points
7 answers One of the answers was accepted by the question author.

Binary NOT in c#

Hello I have a misunderstanding issue...if you can please help me. I get a binary number: 110 for example, in string format and I want to apply the not ~ operator and get 001. I try to convert it to sbyte or byte but for "1" I get 49.…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-01T21:47:53.403+00:00
Keeponfalling 41 Reputation points
commented 2020-12-09T06:50:49.443+00:00
Keeponfalling 41 Reputation points
2 answers

Windows Forms C# application - Automatically handle DPI Scaling when a user sets the display to 125% or 150%

We had designed a Windows Form application such that it is suitable for all the resolutions. We came across a situation where the applications appear to be incorrectly sized when the user chooses 125% or 150% in the machine display setting . I have set…

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,831 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T06:29:03.803+00:00
Srinivas Kamalanathan Attipattu 1 Reputation point
commented 2020-12-09T05:53:16.607+00:00
Daniel Zhang-MSFT 9,611 Reputation points
2 answers One of the answers was accepted by the question author.

Use a String from a "try catch" in another "try catch"

Hello, how can I use a String inside a "try catch" outside in another "try catch"? I need the string "server_token_string". string server_token_string; try { using…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T23:09:29.247+00:00
RobinJ 276 Reputation points
accepted 2020-12-08T16:31:44.35+00:00
RobinJ 276 Reputation points
4 answers

Reading big files while file may be still copying into the folder

Hi everybody, We seem to be getting an error on a regular basis at the same time. The error occurs when we try to read the file and when we check properties of that file in the Windows Explorer we can see that there are 2 dates: Creation Date and…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T23:28:47.18+00:00
Naomi 7,361 Reputation points
answered 2020-12-08T16:10:25+00:00
Karen Payne MVP 35,036 Reputation points
0 answers

Why sometimes windows service app can't build dynamic assembly?

I have some server app. This app run, read some files, create C# classes, build this and load assembly. This app can work in two modes - one mode is window desktop application, and other mode - as windows service but core in dll is common. …

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T15:14:09.353+00:00
Łukasz Gabryel 1 Reputation point
commented 2020-12-08T14:35:40.923+00:00
Viorel 112.3K Reputation points
0 answers

prevent the program from hiding the mouse cursor

I'm working on a touchpad program and i avoided mouse position changes by this code: public partial class MouseHooker { public MouseHooker() { _hookID = SetHook(_proc); } private static readonly LowLevelMouseProc _proc =…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T18:10:44.13+00:00
MainSilent 1 Reputation point
commented 2020-12-08T10:15:25.673+00:00
Cheong00 3,471 Reputation points
2 answers

How do I clear a remote session after publishing my C# MVC application from Visual Studio?

So I have my C# MVC application, happy with its design, I publish the application onto external servers (ionos), once I've published I've found if I create a new account or go to log into the application its like the session is still hanging around. As…

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,177 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,613 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-05T21:56:20.873+00:00
martin cooke 1 Reputation point
commented 2020-12-08T07:04:24.903+00:00
Bruce Zhang-MSFT 3,736 Reputation points
2 answers

C#: Send email via SMTP

Hi all, I am attempting to develop a process that sends automated notifications via email. For development, and having a gmail account handy, I followed the instructions in this video: C# SMTP in Action : How to Send Email in C# using Gmail (Aug.…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T18:39:47.367+00:00
Saga 426 Reputation points
answered 2020-12-08T05:47:22.93+00:00
Nitish Kumar 6 Reputation points MVP
2 answers

The required column 'FirstName' was not present in the results of a 'FromSql' operation.

Hello, I have a stored proc that I'd like to return a portion of the fields that are in my model. If I don't return every field in my model, I'm getting "The required column 'FirstName' was not present in the results of a 'FromSql'…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-07T13:43:34.837+00:00
Venkata Prasad Pinapathruni 1 Reputation point
answered 2020-12-07T15:37:03.743+00:00
Karen Payne MVP 35,036 Reputation points
0 answers

Not able to call C# function for CosmosDb Change feed from power shell

I am able to run the below code, if I run it as a console application, Now my requirement is that InstanceTime, ProcessorName and ChangeInstance is passed as an argument from PowerShell and run this method and get the required changed documents output. I…

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,445 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-04T15:50:20.943+00:00
Ankit Kumar 91 Reputation points
commented 2020-12-07T14:03:41.147+00:00
Ankit Kumar 91 Reputation points
1 answer

Best practice for handling async dispose using lock/semaphore

I have run into an issue where I have a async method that disposes of resources asynchronously. This method needs to be multithreaded as potentially it can be called at the same time depending on circumstances. Using a plain lock won't work because you…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-04T20:19:51.727+00:00
Chris Stopher 6 Reputation points
commented 2020-12-07T13:26:34.59+00:00
Slav Ivanyuk 1 Reputation point
1 answer

How to create instance of Win32 COM object?

I have some legacy code that need to port over to C#. There is a COM server object written in C++ that is called by other Win32/MFC apps. I'm trying to see if I can write a C# app and create an instance of the COM object just like the other Win32/MFC…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-05T02:38:48.753+00:00
Leo Ayala 21 Reputation points
commented 2020-12-07T10:34:53.35+00:00
RLWA32 40,471 Reputation points
0 answers

Why does AudioPlaybackConnection keep disconnecting from Bluetooth devices in non-UWP applications?

I've created a test method in C# to connect to Bluetooth devices through the newly introduced AudioPlaybackConnection class in the WinRT API. I see that AudioPlaybackConnection is marked with the DualApiPartition attribute, so it should work in desktop…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,121 questions
asked 2020-12-07T03:54:33.293+00:00
Brian Mak 1 Reputation point
3 answers One of the answers was accepted by the question author.

How to use both sub-classes in C#

Hi All, I want to how to use both subclasses "InterestEarningAccount" and "LineOfCreditAccount" in the same program. TIA sub class InterestEarningAccount using System; namespace Inherit3 { public class InterestEarningAccount :…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-04T09:14:13.203+00:00
BenTam 1,561 Reputation points
accepted 2020-12-07T03:34:59.213+00:00
BenTam 1,561 Reputation points
0 answers

[UWP][BLE][C#]How to identify last packet for large data in BLE Write and Notify in Win10

I have a Windows class library that uses UWP BLE APIs. The setup is: BLE Host: Win 10 laptop BLE peripheral: Win 10 laptop or Android I need to send large file (a few K to a few M) to and from peripheral (using Write/WriteWithoutResponse and Notify)…

Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-02T03:31:44.797+00:00
Angela Yan 1 Reputation point
commented 2020-12-07T03:23:45.48+00:00
Roy Li - MSFT 32,011 Reputation points Microsoft Vendor
1 answer

C# Platform Invoke ADUser Constructors parameterless

Hi Developers ! I'am a newer of C#,once i want to practice how to Invoke Unmanaged code And i got the Assembly:Microsoft.ActiveDirectory.Management.dll,to practice how to use ADUser Constructors to create an abject whose properties are similar to a…

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-12-06T07:06:38.437+00:00
cook bada 1 Reputation point
answered 2020-12-07T02:33:40.653+00:00
Daniel Zhang-MSFT 9,611 Reputation points
4 answers

Float type in database but the number becomes different after getting to C#

In database, there is a field in "float" type. There is a record with 300.88. (correct value) After getting into DTO ("double" type), it becomes 300.87999988 After passing DTO to textbox in view, it displays 300.88 correctly. …

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,267 questions
asked 2020-11-26T23:22:55.097+00:00
Jikha 1 Reputation point
commented 2020-12-06T15:08:39.153+00:00
jikha 1 Reputation point