Microsoft Q&A

C#

6,920 questions

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.

Browse all C# tags

6,920 questions with C#-related tags

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

EF Core 6 - Truncate Table

Hi, How can I use the truncate table in EF Core 6? I tried this but didn't delete rows. _oyunPalasContext.RazerReconciliation.FromSqlRaw("TRUNCATE TABLE RazerReconciliation");

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.
6,920 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2023-01-25T06:54:42.34+00:00
Cenk 666 Reputation points
answered 2023-01-25T11:22:57.64+00:00
Karen Payne MVP 29,226 Reputation points Microsoft MVP
2 answers

How to use C# Linq to find average value of a double list.

Hello: I have the following data: List<double[]> asks = new(); var ask1 = new[] { 4.0, 4.0 }; var ask2 = new[] { 5.0, 5.0 }; asks.Add(ask1); asks.Add(ask2); List<double[]> bids = new(); var bid1 = new[] { 3.0, 3.0 }; var bid2 = new[] { 2.0,…

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.
6,920 questions
asked 2023-01-23T20:40:50.73+00:00
john zyd 406 Reputation points
answered 2023-01-25T11:04:02.42+00:00
john zyd 406 Reputation points
0 answers

Best way to unit test cancellation

Good evening. I have been trying to write a unit test that will test the cancellation of a method. Now I have a unit test written that passes, but I am do not think it is what I am looking to achieve. I have tried a few different ways to achieve 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.
6,920 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying a test as a means of analysis or diagnosis.
249 questions
asked 2022-07-22T02:01:05.437+00:00
Michael Mastro II 26 Reputation points
commented 2023-01-25T09:50:02.16+00:00
Christoph 0 Reputation points
0 answers

Why is the combo box cursor/caret moves to the beginning when down arrow is hit?

In my app I have a combo box <ComboBox ItemsSource="{Binding ComboItems}" SelectedItem="{Binding SelectedCBItem}" StaysOpenOnEdit="True" Text="{Binding SelectedCBItem,…

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,170 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.
6,920 questions
asked 2023-01-23T05:18:53.03+00:00
don bradman 371 Reputation points
commented 2023-01-25T09:15:22.2633333+00:00
don bradman 371 Reputation points
1 answer

filter & save to xml function doesnt work viewmodel

Hello Morning: First i read xml file to fill the datagrid edit, save the xml file, then export the datagrid to excel file using OpenXML, then read the excel file to fille the datagrid. When i jsut read the xml file, i can filter the datagrid and edit…

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,170 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.
6,920 questions
asked 2023-01-23T15:35:49.1233333+00:00
Kran2022 241 Reputation points
commented 2023-01-25T09:09:52.5933333+00:00
Kran2022 241 Reputation points
1 answer

Blazor Server - System.InvalidCastException: Unable to cast object of type 'System.Double' to type 'System.Single'.

Hi, In my Blazor server application, I am trying to get the records from RazerReconciliation table as follows. I couldn't figure out why I am getting this error. public async Task<List<RazerReconciliations>> GetOldReconsAsync() { var…

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.
6,920 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
783 questions
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
420 questions
asked 2023-01-25T06:21:35.1233333+00:00
Cenk 666 Reputation points
edited an answer 2023-01-25T06:42:04.0533333+00:00
Viorel 82,381 Reputation points
1 answer

401 Unauthorized when Granting access via Azure AD App-Only

I followed this article but I modified the sample code a bit to use GetContextAsync instead of GetAzureADAppOnlyAuthenticatedContext AuthenticationManager authManager = new AuthenticationManager(clientId, certPath,certPassword,tenantId); 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.
6,920 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,575 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
5,977 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
1,665 questions
asked 2023-01-25T03:58:59.3433333+00:00
Jack Le 0 Reputation points
answered 2023-01-25T06:35:57.4533333+00:00
RaytheonXie_MSFT 14,226 Reputation points Microsoft Employee
2 answers One of the answers was accepted by the question author.

CollectionView UI not updated when Switch Toggled but ObservableCollection updated

Here, when toggle, observablecollection has been updated, but ui not updated. Expected Output is: When switch toggle is on, the items pack price need to be display. When switch toggle is off, the item's price need to be display. <CollectionView…

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.
6,920 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
556 questions
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,803 questions
asked 2023-01-24T19:30:26.5+00:00
Mohanasundharam Murugan 20 Reputation points
answered 2023-01-25T06:18:15.31+00:00
Mohanasundharam Murugan 20 Reputation points
2 answers

WPF ListBox - Display Message When Item Source Is Empty

Hello All - I am trying to replace the listbox with a message for the user when there is no data available. When there is data available, whatever is available, will display out. I have been working on this for a while but do not know what to do. When…

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.
6,920 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
556 questions
asked 2023-01-25T01:47:40.06+00:00
bryon 101 Reputation points
answered 2023-01-25T06:10:16.9533333+00:00
Hui Liu-MSFT 14,556 Reputation points Microsoft Employee
1 answer One of the answers was accepted by the question author.

How to detect Windows Application Dark mode

What is the way to detect windows application dark mode setting (If it is dark or light), in a C# WPF application. Settings > Personalization > Colors > “Choose your default app mode” Screenshot from Windows 10 operating system. I am aware of…

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.
6,920 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,170 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
1,888 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
125 questions
asked 2023-01-17T13:57:13.0533333+00:00
Deshmukh, Gaurav 30 Reputation points
commented 2023-01-25T05:04:29.7633333+00:00
Deshmukh, Gaurav 30 Reputation points
3 answers

after running code , this error show i am using window 10, C#, Asp.net, Bootstrap, JavaScript, Html lang

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.
6,920 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
443 questions
ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
390 questions
asked 2023-01-24T09:23:53.4466667+00:00
Rupa Kumari 0 Reputation points
answered 2023-01-25T04:44:15.96+00:00
Albert Kallal 3,446 Reputation points
2 answers

C# code to check the first character in the string is an integer and then convert to hex if integer

In the input script, check the first character of the input parameter. If it is a digit value, then convert the integer to hex. For example input is 7fph7vfxbvkl then output becomes _x0037_fph7vfxbvkl .looking for a c# script for this Thank 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.
6,920 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
599 questions
asked 2023-01-24T19:52:49.2266667+00:00
Sree 0 Reputation points
answered 2023-01-25T02:17:49+00:00
Jack J Jun 19,036 Reputation points Microsoft Employee
0 answers

How do I add my company subscription Id?

Hi all, I would like to add my company Subscription ID to my subscriptions. Is that possible?

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.
6,920 questions
asked 2023-01-24T22:55:45.2633333+00:00
Diego Contreras 0 Reputation points
commented 2023-01-25T01:36:34.0033333+00:00
Jack J Jun 19,036 Reputation points Microsoft Employee
3 answers

How to open or launch my desktop application(windows application) developed using C# in browser

I have to launch or open my desktop application developed using C# in the browser? please give me some suggestions on how to achieve it ? Thanks in advance. Explanation: I have a windows app XYZ.exe so I need to open this application from the browser. so…

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.
6,920 questions
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,314 questions
asked 2023-01-23T06:11:55.94+00:00
Dineshkumar.S 306 Reputation points
commented 2023-01-24T22:07:29.52+00:00
Reza Aghaei 2,851 Reputation points Microsoft MVP
1 answer One of the answers was accepted by the question author.

InputTransparent not working on a BoxView?

It appears the InputTransparent is not working properly? I set it to false, yet any controls underneath still receive taps. <AbsoluteLayout VerticalOptions="Fill" BackgroundColor="#5774ED"> <ActivityIndicator…

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.
6,920 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
876 questions
asked 2023-01-22T23:49:05.59+00:00
Phunction 176 Reputation points
commented 2023-01-24T21:38:40.9+00:00
Phunction 176 Reputation points
1 answer

using FileSystem.OpenAppPackageFileAsyn to open and play mp3 files stored on Google Drive

Hi I am using VS 2022 and C# to develop a MAUI App which needs to be deployed for IOS/Android and Windows. I would like to play audio files that are stored on Google Drive using audioPlayer. Can I use FileSystem.OpenAppPackageFileAsyn to open the file,…

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
876 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.
6,920 questions
asked 2023-01-22T22:11:13.7033333+00:00
Riffy 206 Reputation points
commented 2023-01-24T20:37:15.5866667+00:00
Riffy 206 Reputation points
1 answer

Is it possible to show a hover highlight feature while dragging and dropping in C#?

My program has this code but it isn't coming together right. I'm wondering if this is even possible. ListViewItem prevSelected = null; private void List_MouseLeave(object sender, EventArgs e) { if (prevSelected != null) …

.NET
.NET
Microsoft Technologies based on the .NET software framework.
599 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.
6,920 questions
asked 2023-01-24T01:35:24.2+00:00
Spamzilla 41 Reputation points
answered 2023-01-24T20:35:37.58+00:00
Spamzilla 41 Reputation points
0 answers

How to search dictionary key and find the value in C#?

Hello: I have the following Json data stored into one dictionary: public class JsonKey { public int? Index { get; set; } public string? ID { get; set; } public string? Name { get; set; } …

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.
6,920 questions
asked 2023-01-24T20:34:08.8733333+00:00
john zyd 406 Reputation points
0 answers

How to use Json Data as dictionary key and find the value?

Hello: I have the following Json data stored into one dictionary: (newtonsoft.json) public class JsonKey { public int? Index { get; set; } public string? ID { get; set; } public string? Name { get; set;…

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.
6,920 questions
asked 2023-01-24T20:30:06.5233333+00:00
john zyd 406 Reputation points
5 answers

Unable to call handler in Razor page from JQuery

I'm trying to call a handler in my Razor code behind to bind a table and it's not getting executing. CS code: public async Task<JsonResult> OnGetCarList() { var cars = await _context.GetCars.ToListAsync(); return new…

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.
6,920 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,531 questions
asked 2023-01-24T14:29:16.1966667+00:00
TheCoder 91 Reputation points
commented 2023-01-24T19:45:19.3833333+00:00
Karen Payne MVP 29,226 Reputation points Microsoft MVP