The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [c#]

C# (pronounced "see sharp") is a high level, statically typed, object oriented programming language developed by Microsoft. C# code usually targets Microsoft's .NET family of tools and run-times, which include the .NET Framework and .NET Core. Use this tag for questions about code written in C# or C#'s formal specification.

-5
votes
0answers
13 views

write a function that will operate on a string and escape all instances of '<' '>' and '\' with a '\'

Your function should handle strings of arbitrary length. If you have any questions about the problem, make reasonable assumptions and state your assumptions in your reply. for example: passing in "...
0
votes
0answers
9 views

EF Core - conditional relationship - vertical table splitting

I've to deal with a special relationship, due to an existing database schema. The db: - table Cat (id, name) - table Dog (id, name) - view Animals: SELECT 'C' + CAST(Id AS VARCHAR) AS AnimalId, Id AS ...
0
votes
0answers
7 views

How can I make Skype for business Lync messages open automatically in front

I'm looking for a way to make skype messages open automatically and in front of RDP sessions. The notification pop-up is not enough because I have users than walk away from their computers but leave ...
0
votes
0answers
8 views

IIS express problem. Error 502.5. Help Alert

I still have problem with my application created in asp .net core. Probles is: 1. HTTP Error 502.5 - Process Failure 2. Event logs: Application 'MACHINE/WEBROOT/APPHOST/BIGPROJECT' with physical root ...
-1
votes
0answers
13 views

Developing an interface where the user can search for clients using customer ID, national ID and names as filters [on hold]

The Android App must connect be linked to a web service to store and retrieve records. The web service should be created using either: 1. PHP and mysql. You are free to use any PHP framework; but we ...
1
vote
2answers
27 views

How can i re-use a code in monobehaviour class?

First i'd like to give a short version of my question: How can i access another code pieces attached to another game object, or how can i initiazlie a class without have an game object attched. When ...
0
votes
0answers
11 views

WPF ComboBox in grid - how to specify search path in viewmodel

We have a DataGridTemplateColumn that uses a ComboBox in the DataTemplate: <DataGridTemplateColumn Header="Things"> <DataGridTemplateColumn.CellTemplate> ...
0
votes
0answers
10 views

How do I set if condition for sprite renderer?

I'm trying to have an if condition to do something if the sprite renderer of another object is enabled, but it won't work. Here's the code I tried: using System.Collections; using System.Collections....
-1
votes
0answers
16 views

C# WPF decompiling and obfuscation

Is it easy to decompile a C# binary? When reading How do I decompile a .NET EXE into readable C# source code? it seem fairly easy. If it is easy to decompile, how do one obfuscate the source code? I ...
-5
votes
1answer
29 views

Hello everyone , I ask about how to Convert text to binary then convert to image asp.net C#

this is my code : string str = "Hello World"; byte[] arr = System.Text.Encoding.ASCII.GetBytes(str); image.Src = "data:image/png;base64," + Convert.ToBase64String(arr);
1
vote
2answers
22 views

How can I copy a file from program's resources to a specific location?

First I tried this code: File.Copy(Properties.Resources.files,"c:/files.zip"); But I get this error: Argument 1: cannot convert from 'byte[]' to 'string' After that i tried to add at finish of ...
0
votes
0answers
12 views

Problem with running batch files from within my application

I've been trying to create a simple application to backup my Windows Server databases aswell as a whole server backup. For this I want to use batch files which are being executed by my application. I ...
-4
votes
0answers
30 views

System.OverflowException: 'Value was either too large or too small for an Int32.' [duplicate]

i have a string that contains this 16-bit binary number "11000011100010110001111001001100" i want to convert it to integer so i can do arithmetic operations i tried Convert.ToInt32() and Convert....
0
votes
0answers
23 views

How to fix NullReferenceException when uploading an image using HttpPostedFileBase?

I am building the user registration using Microsoft identity. Everything is working fine except for the user image I keep getting a NullReferenceException! I already added the userimage field to the ...
-1
votes
0answers
9 views

How to mocking generic DbRawSqlQuery<int>?

How to mock DbRawSqlQuery? I need that return 1 var rawMock = new Mock<DbRawSqlQuery<int>>(); rawMock.Setup(i => It.IsAny<int>()).Returns(1); But i have error: Invalid setup on ...
-3
votes
1answer
36 views

How to make string inputs case insensitive in C#?

So, in my quest to learn C#, I am attempting to create an interactive story that changes based on some of the input that the user had submitted. If the user types in "Bobby" in this case, the narrator ...
0
votes
0answers
14 views

How to get the original values from a navigation collection property in Entity Framework Core?

With Entity Framework Core, I need to check the original values of a navigation property inside my entity but i can't find a way to do it. I'm able to read the original and the current values of the ...
0
votes
1answer
38 views

LINQ statement using one of two parameters

I'm working on a LINQ statement. I have a table of cities where the records have either a countryId or a stateId. I'd like to just write the one statement and have the where clause check to see which ...
-1
votes
0answers
9 views

NSubstitute Received() fails when it shouldn't for static arrays

Using NSubstitute 4.0.0, I'm testing that a number of calls occur on an IWriter interface: public interface IWriter { void Write(byte[] bytes, int offset, int length); } My test is as follows: ...
-1
votes
2answers
28 views

How can I separate the contents of a single textbox in a c# destop application into two interger variables?

I'm trying to create a simple desktop application where you can do operations with fractions. I created the Rational class but i need a denominator and numerator. I can only use 2 textboxes, one for ...
0
votes
1answer
21 views

Add Properties from Different Lists on Matching ID

I'm pulling data from two sources with a common ID. One set of data has metadata while the other does not. I want to end up with one list that has the common information. public class Record { ...
0
votes
0answers
6 views

Change the color of the top and bottom bar (ControlsBar, StatusBar) in a Xamarin.Forms app

Is there anyway, even if requires platform specific code behind, to change the color of both the top bar (the one in blue) and the bottom bar (the one in black)? I wish to add support for light and ...
0
votes
0answers
27 views

Draw continous line from unordered points

I have sets of lat/long coordinates that comprise of several polylines. Each set of coordinates is a continuous line. For example (displaying latitudes only), Set 1 = 29.61357,29.61204,29.60898,29....
0
votes
2answers
20 views

Grouping a List and selecting the required item after ordering

I have a List of type Course with around 100 rows. Course has 3 columns: Code, Description and Year. So the list currently looks like: Code Description Year A200 DataB 2018 A200 ...
-6
votes
1answer
36 views

Why it is always a best practice to reduce or solve all the warnings? [on hold]

My question is general software development both frontend, backend. Either working on C# based APIs or front end web or native application using javascript framework (Angular, Vue, react etc). Is it ...
0
votes
1answer
15 views

UdpClient wont connect to IpAdress.Any

I'm trying to listen for UDP packets from unknown source. But can't bind on the "unspecified adress" (0.0.0.0 or ::) I've already tried listening on ::1. But from what i tested that only works for ...
-2
votes
0answers
9 views

How to fix 'The object reference has not been set to the instance of the object.' error while there is more than two inline 'AddField' thing [duplicate]

Whenever a command have more than 2 AddField things, in bot's debug console it shows error 'The object reference has not been set to the instance of the object.' I tried changing inline to false, but ...
0
votes
0answers
6 views

Always Encryption using Azure Function - Trying to Avoid Duplicate Initialization via Static Variables

I'm using an Azure Function to store encrypted data. I have successfully done so using the code below; however, trying to initialize key store providers more than once throws an error, Key store ...
0
votes
0answers
20 views

How could I get the selected item from multiple dynamically added Select2 dropdowns?

I am working on a C# Asp.Net web application, and I am trying to add the ability to dynamically add some select2 dropdowns on our project creation form. So far, I've been able to add a single ...
0
votes
0answers
19 views

Pooled and NonPooled connections

My application is running on Windows Server 2106 with 24 CPU and 16 GB RAM, using PostgreSql 11.2 as a database on a separate CentOS 7 server. Application is written with C# 4.7.1 using Npgsql 4.0.6. ...
1
vote
1answer
39 views

How do I print clear text from a windows form?

I have successfully printed a windows form, but all the text is slightly blurry. I have concluded that this is a result of the resolution of the screen being much less than the resolution the printer ...
-1
votes
0answers
14 views

“await authenticationContext.AcquireTokenAsync” not running when called in Restful API

Sorry for the poor title, but I'm not getting an error, it just isn't running. I am trying to authenticate to our Dynamics 365 to get an Access Token so I can send data using the Dynamics API. The ...
0
votes
0answers
18 views

iTextSharp is not working with foreach loop

I'm trying to insert images to a pdf file and this code is working right without foreach loop, but not working with foreach loop. Positions of images (top, left) are saved in data base, so foreach ...
0
votes
0answers
20 views

How will an XML file generate two other files? One would contain a C# class and the other is a configuration file

In a C# app I have to use a web service to download some data. I have an URL that contains 1 XML file. It is said that it will generate two other files: one with the C# class that I have to use to ...
-3
votes
1answer
56 views

Write single stored procedure for insert and update

How to write a single stored procedure for insert and update? I am taking single button for insert records and also to update records. I am also taking a hidden field, so like after clicking that ...
1
vote
0answers
20 views

Binding HttpListener to https on specific port in Linux/Ubuntu

I have created a HttpListener in .netcore to listen on a specific port for incoming requests, I need to bind an ssl cert to the port 8202 on Ubuntu (version 18.04.2 LTS) but unsure how. My googling ...
0
votes
1answer
52 views

Communication between two Forms C#

I have three forms, the main form which it's calling the Form2 and the Form2 has the Form3 as constructor and same thing for the Form3 (constructor of the Form2). In fact, I'm trying to put ...
0
votes
0answers
16 views

What's the fastest way to accomplish the globalization of an asp.net mvc site's resources?

I need to find a quick way to globalize all the strings of a web system. Is there a library/package or good practice for me to make this change?
1
vote
1answer
28 views

unable to do multiple matches with regex pattern. pattern treats as a single match

I'm trying to match a pattern out of text which repeats with in the text. when i try match pattern it matches whatever in between. though I achieved the desired result but i might want any ...
-4
votes
0answers
34 views

Implicitly typed new expression C# 8.0 doen't work with VS 2019

Implicitly typed new expression C# 8.0 doen't work with VS 2019 I've installed VS 2019 which also has C# 8.0, though when i try to implement Implicitly typed new expression , it doesn't work. Same ...
-2
votes
0answers
18 views

Intermittent data and what to look for in WebApi

When testing my application I'm seeing different data set every time even for the same region(Intermittent). There is a different count in the data set. What should I look for in the API for a ...
0
votes
0answers
12 views

Can I change the configuration names that Visual Studio Installer uses in 'add project output'

I have a C# project that targets five dot net frameworks (using property group conditions in csproj) to produce a build for each. When I click 'Add Project Output' in my Visual Studio Installer ...
0
votes
0answers
11 views

How to edit existing Spreadsheet and insert new cell into each row

I'm using OpenXml SDK to edit existing spreadsheet. Spreadsheet has SheetData with set of rows. I need to insert new cell (with value) into each existing row. As result existing cells for specific row ...
-2
votes
0answers
11 views

Re-Create new Docx File from the WordProcessingML Document

I have store the document.xml(WordProcessingML ) of a docx file in SQL table. an example This is image of WordProcessiongML in sql I would like to export it into word(.Docx) again with formatting. ...
-1
votes
1answer
21 views

Unable to deserialize Json string array of arrays into object when using Newtonsoft.Json

i am using Newtonsoft.Json and trying to deserialize an array of arrays Json string into C# object i created. This is the json string - [4615,4618,4619,4626,4615,4626,4631,4636,4637],[4615,4618,...
-2
votes
0answers
23 views

Programming a number keypad and getting System.InvalidCastException: c#

I am creating a keypad, similar to a calculator but with different function. When a number button is pressed i want it to show in a text box. but keep getting an error message. this is the code i have ...
-3
votes
0answers
28 views

solution to programmatically save files to different locations [on hold]

I have a windows service that automatically downloads video content for a city agency. I've been asked to rework the service so that we can save files to multiple locations - if one disk fills up, we'...
0
votes
0answers
25 views

Unable to cast object of type 'System.String' to type 'System.Byte[]'. fetching data

I am trying to fetch image from database and i am getting this error Unable to cast object of type 'System.String' to type 'System.Byte[]'. here is my code job.CompanyLogo = "data:Image/jpg;...
0
votes
1answer
20 views

GitLab: Project Not Found: Runs Fine Locally, Doesn't Work Deployed

We have an app that updates a gitlab project and pushes/commits to master. When I run locally, the program runs fine. When I run on the application hosted server (not the gitlab server), I get a 404 "...
0
votes
0answers
23 views

How can create a shooting cut scene for a part of my adventure game?

Something more realistic. It's not part of a shooter game it's part of adventure game point and click and a cut scene I want to do at some point in the game that show a close range of a npc changing ...