Search

Tutorials, tips&tricks, snippets..

K.I.S.S.: Keep It Simple, Stupid!

Only numbers in a WPF textbox with regular expressions

Managing the input in your project is very important. In this post, you can see how create a numeric field in WPF, using the regular expressions.

Continue reading “Only numbers in a WPF textbox with regular expressions”

Prevent Copy, Cut and Paste in a XAML Textbox

How can you prevent at least one of copy, cut and/or paste actions in a WPF project? Here how prevent these events in a textbox.

Continue reading “Prevent Copy, Cut and Paste in a XAML Textbox”

Extension Methods #5: check if object has a method

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #5: check if object has a method”

Extension Methods #4: check if object has a property

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #4: check if object has a property”

Extension Methods #3: get property name starting from its own name

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #3: get property name starting from its own name”

Extension Methods #2: toString with NULL values

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #2: toString with NULL values”

Extension Methods #1: truncate a string

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #1: truncate a string”

Generate random strings

private static Random random = new Random();
public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
        .Select(s => s[random.Next(s.Length)]).ToArray());
}

HTTP POST Request with C#

In the following samples, you can find out how to send a HTTP POST request with C#. I work a lot with JSON, so here I’ll show how to send a JSON string. Here we go!

Continue reading “HTTP POST Request with C#”

Create a free website or blog at WordPress.com.

Up ↑