127 Answered Questions for the topic C#
C#
07/09/19
WebBrowser Control - Prevent Right-Click?
In my application, I have a form that contains a browser control in which I display an SSRS report. I would like to prevent the user from right-clicking in the browser control and being shown the...
more
UInt64 and "The operation overflows at compile time in checked mode" - CS0220?
This feels like a stupid question, but I can't seem to see the answer. I have an UInt64, which is supposed to have a max value of
UInt64.MaxValue 18446744073709551615
However, when I try to...
more
C#
07/08/19
Calendar parameter not showing in asp report viewer?
I have created an asp webpage that calls an ssrs report using reportviewer (v11).
The calendar parameter works fine when viewing from the ssrs report server but when viewed from the asp page, the...
more
C#
07/08/19
SSRS report - Merge data from different datasources with the same tables?
I have 2 databases, one is for Employees, and the another one is for Employees that used to work on the company.
both databases have the same tables but with different data (there is no...
more
Is it possible to edit keywords in Lightroom with C#?
Is it possible to access an Adobe Lightroom catalog from outside with C#?I want to get the image, then do some stuff, add some keywords, and write it back in the catalog.Is that possible? Did...
more
C#
07/06/19
Check if Polygon is Self-Intersecting?
I have a System.Windows.Shapes.Polygon object, whose layout is determined completely by a series of Points. I need to determine if this Polygon is self intersecting; i.e., if any of the sides of...
more
07/05/19
C# logic order and compiler behavior?
In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?
Example:
DataTable myDt = new DataTable();
if (myDt != null &&...
more
C#
07/03/19
Is there any algorithm for calculating area of a shape given co-ordinates that define the shape?
So I have some function that receives N random `2D` points.
Is there any algorithm to calculate area of the shape defined by the input points?
07/03/19
How and when to abandon the use of arrays in C#?
Should you try to avoid using an array as much as possible when you will be adding a lot of elements? Should you use iStringMap instead? If so, what happens if you need more than two dimensions AND...
more
C#
07/02/19
get angle of a line from horizon?
I want to know how to get an angle of a line A-B from horizontal axis X. Other questions in SO do that only between two lines. I'm aware I can always draw second line A-C and calculate but I'm...
more
C#
06/30/19
Entity Framework. Delete all rows in table?
How I can quickly remove all rows in table using Entity Framework?
I am currently using:
var rows = from o in dataDb.Table
select o;
foreach (var row in rows)
{
...
more
C#
06/28/19
How to plot a line chart from .mat file in visual studio C#?
Is there a simple way to plot a line chart in windows form application from .mat file generated in simulink simulation?
C# Logic
06/27/19
C# convert a string for use in a logical condition?
Is it possible to convert a string to an operator for use in a logical condition.
For example
if(x Convert.ToOperator(">") y) {}
or
if(x ">" as Operator y){}
I appreciate that this...
more
Check severeal boolean returns in same time?
I have several bool elements and I am checking it if returns me false.
bool i = false;
switch (idcount)
{
case 1: i = p1(); break;
case 2: i = p1() & p2(); break;
case 3: i = p1() &...
more
C#
06/21/19
Calculate coordinates of a regular polygon's vertices?
I am writing a program in which I need to draw polygons of an arbitrary number of sides, each one being translated by a given formula which changes dynamically. There is some rather interesting...
more
Display 1,2,3,4,5,6,8,10,11 as 1-6,8,10-11?
> I have this sequence **1,2,3,4,5,6,8,10,11**
>
> Expected output is **1-6,8,10-11**
This problem is about formatting the sequence in easy readable form
I tried with c# and used many...
more
C#
06/17/19
Proper Trigonometry For Rotating A Point Around The Origin?
Do either of the below approaches use the correct mathematics for rotating a point? If so, which one is correct?
POINT rotate_point(float cx,float cy,float angle,POINT p)
{
float s =...
more
C#
06/16/19
Generate class from database table?
How can i generate a class from a table at a SQL Server?
I'm not talking about using some ORM. I just need to create the entities (simple class). Something like:
public class Person
{
...
more
C#
06/15/19
c# - how to move point a given distance d (and get a new coordinates)?
I was wondering if there is any efficent way to calculating coordinates of point (which was moved distance d from it's original location).
Let's say I have a point P(0.3,0.5) and I need to move...
more
C#
06/15/19
LINQ to SQL - Left Outer Join with multiple join conditions?
I have the following SQL, which I am trying to translate to LINQ:
SELECT f.value
FROM period as p
LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17
WHERE p.companyid =...
more
C#
06/09/19
What is the syntax for an inner join in LINQ to SQL?
I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an `ON` clause in C#.
How do you represent the following in LINQ to SQL:
select...
more
C#
06/07/19
Calculate Gross Profit W/O Sell?
Trying to make myself a small project for work that will calculate gross profit without needing a sell price. Can anyone explain why this is getting marked down? we all needed help at one...
more
C#
06/06/19
Fastest Way of Inserting in Entity Framework?
I'm looking for the fastest way of inserting into Entity Framework.
I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can...
more
C#
06/06/19
get closest point to a line?
I'd like to have a straight forward C# function to get a closest point (from a point P) to a line-segment, AB. An abstract function may look like this. I've search through SO but not found a usable...
more
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.