10,355 questions with C#-related tags

Sort by: Updated
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,468 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,355 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,355 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,355 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,941 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,355 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,130 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,355 questions
asked 2020-12-04T09:14:13.203+00:00
BenTam 1,581 Reputation points
accepted 2020-12-07T03:34:59.213+00:00
BenTam 1,581 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,355 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,466 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,355 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,621 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,355 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
1 answer

Json Navigation

I am getting a string from a Rest API. The string contains a list of orders. string result = await content.ReadAsStringAsync(); dynamic json = JsonConvert.DeserializeObject(result); string res = json[0]["id"]; MessageBox.Show(…

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,355 questions
asked 2020-12-06T07:14:13.157+00:00
Muhammad Ahmed 1 Reputation point
answered 2020-12-06T12:12:54.35+00:00
Karen Payne MVP 35,196 Reputation points
2 answers One of the answers was accepted by the question author.

how to find double code caracter in string

I need to find the position of the double quotation mark (") character in a text that contains several. I read the text with this command: StreamReader fileRead = File.OpenText (@filepath) How can I do? Thanks in advance Marco Dell'Oca

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,355 questions
asked 2020-12-05T13:50:17.777+00:00
Marco Dell'Oca 41 Reputation points
accepted 2020-12-06T10:00:42.247+00:00
Marco Dell'Oca 41 Reputation points
1 answer

How to avoid multiple duplicate interation from data table in c#

int rowidx = 0; //process for each Main Product list mainproduct = //get data table mainproduct of "prod no" //so mainproduct list is "102201" "102202" "102203" …

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,355 questions
asked 2020-12-05T02:59:43.29+00:00
Gani_tpt 1,686 Reputation points
answered 2020-12-06T00:05:58.677+00:00
Bonnie DeWitt 811 Reputation points
1 answer One of the answers was accepted by the question author.

Check if I have a Internet connection

Hello everybody, I need to check if a internet connection exists because the little program i wrote download a file from a server. I found a example but this isn't working?! bool checkInternet = new Ping().Send("google.com", 500).Status…

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,355 questions
asked 2020-12-05T21:57:19.153+00:00
RobinJ 276 Reputation points
accepted 2020-12-05T22:41:19.553+00:00
RobinJ 276 Reputation points
1 answer One of the answers was accepted by the question author.

Write a String to a .txt File

Hey everyone, Can anybody tell me why my code isn't working? I try to write a string to a .txt File. System.IO.File.WriteAllText(confirmation);

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,355 questions
asked 2020-12-05T21:12:55.823+00:00
RobinJ 276 Reputation points
accepted 2020-12-05T21:31:33.53+00:00
RobinJ 276 Reputation points
2 answers One of the answers was accepted by the question author.

if in switch

Hello anybody, Is it possible to use a if in a switch? switch (eingabe) { //Path check/create if(!System.IO.Directory.Exists($@"{localappdata}\Liquid Aqua\API")) …

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,355 questions
asked 2020-12-04T22:53:19.227+00:00
RobinJ 276 Reputation points
accepted 2020-12-05T20:06:28.013+00:00
RobinJ 276 Reputation points
1 answer One of the answers was accepted by the question author.

Datagridview insert new Row after First

Hi, Please I need help , as I am using datagridview when user press enter key its move to next cell instead of new to new row when its reach to last cell upon user enter key on last cell or row its move to new row, the following code is insert new row…

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,355 questions
asked 2020-11-30T18:26:09.073+00:00
Malik Asad Mahmood 126 Reputation points
accepted 2020-12-05T17:03:29.377+00:00
Malik Asad Mahmood 126 Reputation points
2 answers One of the answers was accepted by the question author.

How do we handle Data Row and its column value in another procedure class file from data table using c#

I have employee data table. In that, every row contains more than 100 columns. It's very difficult to handle the same main page all the columns of every row. In that case, Hoe do we pass all column values for processing in separate procedure…

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,355 questions
asked 2020-12-01T15:55:43.07+00:00
Gani_tpt 1,686 Reputation points
accepted 2020-12-05T01:14:51.303+00:00
Gani_tpt 1,686 Reputation points
0 answers

directoryInfo.CreationTime

How do I get the directoryInfo.CreationTime and the Filename in the ListBox (FileList) with Item Text and the Value. I want to display the filename and need the date for something else. private void BindFileNamesToList() { string…

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,303 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,355 questions
asked 2020-12-02T19:59:07.84+00:00
Qamar, Mo 106 Reputation points
commented 2020-12-04T20:20:05.207+00:00
Malam Malam 121 Reputation points
2 answers

Task.Run without wait ?

In .NET core 2.0 application, have requirement to run task in a background. 1 option is to use IHostedService, However can use Task.Run(() => DoSomething(a,b,c)) without wait ? I got to know it is risky, as if any exception occurred in the…

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,355 questions
asked 2020-12-04T05:56:45.903+00:00
Omkar Pimplekar 1 Reputation point
answered 2020-12-04T18:37:20.577+00:00
Karen Payne MVP 35,196 Reputation points
1 answer

I need a parameter that implements multiple interfaces,How should the code be represented?

interface IA { int DoA(); } interface IB { int DoB(); } These are two interfaces. My method needs to implement the parameters of both interfaces. Is there any way to restrict the caller? I've thought about a lot of things That I can think…

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,355 questions
asked 2020-12-04T10:47:17.157+00:00
卡卡 1 Reputation point
answered 2020-12-04T17:52:36.6+00:00
Collin Brittain 36 Reputation points
1 answer One of the answers was accepted by the question author.

How to invoke an API

Can anyone help me....... I'm a fresher and I'm unable to invoke an API in C# code. Could anyone give an answer for this question.

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,355 questions
asked 2020-12-01T15:30:28.217+00:00
Mohd Muzaffar Ahmed 21 Reputation points
commented 2020-12-04T11:48:13.683+00:00
Mohd Muzaffar Ahmed 21 Reputation points