All Questions
Tagged with formatting c#
1,135 questions
0
votes
1
answer
33
views
How can you apply auto format to method calls in variable declarations in Visual Studio?
My auto format rules are set to add a space before and after parens in method calls, but they do not apply if the method call is in the same line as a declaration.
I've gone through the formatting ...
1
vote
1
answer
79
views
how to format all single action methods into a lambda expression methods when saving a file?
my method
public void Method()
{
OneAction;
}
need format in
Method() => OneAction;
1
vote
1
answer
51
views
String formatting removes floating point errors?
I am trying to understand floating point arithmetic a little better. Can somebody please help me understand what is going on in the below example?
using System;
public class FloatingPointMadness
{
...
1
vote
1
answer
75
views
Currency culture formatting nl-NL/BE gives uncorrect format
I'm trying to write a currency in the Dutch format:
€1.000,00
meaning:
Euro sign before the amount
Between thousands a dot
Between cents a comma
However when I use CultureInfo "nl-NL" or &...
1
vote
2
answers
68
views
C# Linq statement block-style alignment
I'm working with Rider/ReSharper and formatting C# code in block style to improve readability. I can't find (in the settings or on the internet) a way to format LINQ statements as follows:
static Game&...
0
votes
1
answer
59
views
Trouble updating borders in Google Spreadsheet via C# [duplicate]
I'm having difficulty updating the borders in a Google Spreadsheet using C# and Google's API. I have authorized access to the sheet and can update the cell contents. I just can't figure out what I'm ...
0
votes
0
answers
25
views
OpenXml sdk - DocumentFormat.OpenXml - Excel - Create Custom Icon Set for Conditional Formatting
I am trying to set up conditional formatting in an Excel file using the DocumentFormat.OpenXml library. Specifically, I want to use a red X and a green checkmark from the ThreeSymbols icon set. ...
2
votes
1
answer
67
views
Calling ToString with own IFormatProvider doesn't work
This is about IFormattable and IFormatProvider. For sure one can achieve a reversed string representation of value 123 otherwise...
Every C# base data type implements the IFormattable interface. So ...
-6
votes
1
answer
81
views
I can't get my string to display properly
So basically, the below code should display the following. "This text variable1 then this text variable2 followed by this text"
textBox1.Text = string.Format("This text {0} then this ...
0
votes
1
answer
60
views
How do I format this richTextBox text?
I am building an app to suggest dates (romantic dates, not almenac dates) based on inputs by the user. In the end, I want to output the inputs into a richTextBox and format it to look something like:
...
27
votes
2
answers
2k
views
Why is the month abbreviated differently when the date format includes a slot for days as opposed to when it doesn’t?
When running a .NET 8 console application, why does MMM show "June" instead of "Jun" when its part of a date format (e.g. .ToString("dd-MMM-yy")) but "Jun" (e.g....
0
votes
1
answer
303
views
how to Customize autoformatting of C# Code in visual Studio 2022
I want to format C# code in visual studio as image shows:
but once auto formatted run on save I get below code
I want auto save keep working but keep such alignment as is
tried to format code as ...
0
votes
2
answers
86
views
How to format an array of numbers into a string in C#?
The method String.Format has the following overload:
public static string Format (string format, params object?[] args);
which I supposed was meant for formatting many args of the same type into a ...
2
votes
1
answer
593
views
How to use NumberFormatInfo
I want to be able to format any decimal number as I want.
Specifically I want to be able to control:
the number of decimals
the decimal separator
the thousand separator
I have tried to do that
var ...
1
vote
1
answer
112
views
Resharper adding a lot of spaces between method parameter type and name
Given the following code:
internal interface IMyInterface
{
bool MethodOne(string parameter);
bool AVeryVeryVeryVeryVeryLongMethodName(string myParameter);
}
internal class MyClass : ...