Contents tagged with C#
-
Connect to GCP Vertex AI endpoint in .Net AWS Lambda
Authentication
Application Default Credentials (ADC) is a strategy used by the Google authentication libraries to automatically find credentials based on the application environment.
ADC searches … more
-
Using async in web forms
The .aspx markup<%@ Page Title="Async" Language="C#" CodeBehind="Async.aspx.cs" Inherits="Whatever" Async="true" %> The C# code behind: public void Page_Load(object sender, EventArgs e) { … more
-
Exception Handling in C# 6.0
In C# 6 the exception condition/ exception filters feature was added.try { // work } catch (Exception ex) when ( /* filter expression */ ) { //handle exception } The general rule is: … more
-
Convert an Excel Column Name into Index
public static string GetExcelColumnName(int columnNumber) { int dividend = columnNumber; string columnName = string.Empty; int modulo; while (dividend > 0) { modulo = … more
-
Converting Stream to String and back
I want to serialize objects to strings, and back.string test = "The sly fox ..."; // convert string to stream byte[] byteArray = Encoding.ASCII.GetBytes(test); MemoryStream stream = new MemoryStream( … more
-
Is there a C# IN operator?
The short answer is “No”. The long answer is you can achieve a similar result using extension methods:/// <summary> /// Array extention methods /// </summary> public static class … more
-
Reverse sentence word order
This is a fairly common task and the are a lot of solutions out there.One of the more efficient ones would be using the StringBuilder class:static void Main(string[] args) { string sentence = … more
-
How to verify multiple Excel columns are equal
Let’s say we want to compare columns A, B, C and D in row one. The corresponding formula would be:=IF(A1=B1=C1=D1, "Y","N")Unfortunately this will not work. Here’s how this formula should evaluate:= … more
-
How to start a process from C#?
Here’s what I’m trying to achieve:Start a new process for each new task.Communicate the result of the process to the parent process.How to start a new process:Process process = new Process(); // … more
-
How do I open a file in C#?
Have you ever found yourself in a situation where you have to generate a file in Visual Studio and then you have to go to the folder, find the file and open it? Possibly 1,000,000,000 times a day?…OK, … more
-
How to create an Excel Spreadsheet with charts
References:How to: Insert text into a cell in a spreadsheet document (Open XML SDK)How to: Merge two adjacent cells in a spreadsheet document (Open XML SDK)How to: Insert a chart into a spreadsheet … more
-
Resize Excel Table
I’m going to show you how you can resize an existing Excel table. Let’s assume you have the following table in excel (A1:C6): And you want to resize the table to a table like … more
-
What's the difference between String and string?
In C# the string keyword is an alias for String class in the .NET Framework. The String class represents text as a series of Unicode characters.Thus the following two lines are equivalent in C#: … more