public class NullableFloatToNullableDoubleConverter : ITypeConverter<float?, double?>
    {
        public double? Convert(float? source, double? destination, ResolutionContext context)
        {
            if (source == null)
            {
                return null;
            }

            var floatAsString = source.Value.ToString(CultureInfo.InvariantCulture);

            return double.Parse(floatAsString);
        }
    }
By Anonymous, 2019-01-31 12:05:33
        protected override void OnStartup(StartupEventArgs e)
        {
            Current.DispatcherUnhandledException += ApplicationUnhandledException;

            base.OnStartup(e);

#if (DEBUG)
            RunInDebugMode(e.Args);
#else
            RunInReleaseMode(e.Args);
#endif
        }

#endregion

        private static void RunInReleaseMode(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;

            try
            {
                SplashScreen screen = new SplashScreen(@"Images\splashscreen.png");
                screen.Show(true, true);

                RunInDebugMode(args);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }

        private static void RunInDebugMode(string[] args)
        {
            var bootstrapper = new Bootstrapper();
            bootstrapper.Run();
        }
By Anonymous, 2019-07-09 09:44:00
    if (model.env.Trim().ToUpper() == "Release")
    {
        retVal = false;
        if (!string.IsNullOrEmpty(model.Server_Core))
        {
            // Perform a trim in case user specified just whitespace...
            string tmpStr = model.Server_Core.Trim();
            if (!string.IsNullOrEmpty(tmpStr))
            {
                retVal = true;
            }
        }
    }
By Anonymous, 2019-02-25 17:12:31
public partial class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }

      protected override void OnLoad(EventArgs e)
      {
         base.OnLoad(e);
         var token = new CancellationTokenSource().Token;
         Task.Factory.StartNew (() => {
            while (!token.IsCancellationRequested) {
               try {
                  if (/*Condition*/)
                     this.Invoke(new Action(() => label.Text = " =)"));
                  else
                     this.Invoke(new Action(() => label.Text = " =("));
                  Thread.Sleep(10);
               }
               catch (Exception) {
                  throw;
               }
               finally {
                  throw new Exception();
               }
            }
         }) ;
      }
   }

My collegue's way of using multithreading features (and exceptions handling) :)

By Loganjii, 2019-10-09 15:00:18
if (string.Compare(json["result"].ToString(), "OK", true) == 0)
{
    if (string.Compare(json["list"][0]["result"].ToString(), "OK", true) == 0)
        return null;
        
    //omitted
}
By J@k3R, 2022-08-09 08:51:55
    public static class DecimalHelpers
    {
        /// <summary>
        /// Format a decimal XX.XX to XX,XX%.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string FormatToStringPercentageValue(this decimal value)
        {
            return value.ToString().Replace(".", ",").FormatToPercentageValue();
        }
    }
    
    public static class StringHelpers
    {
        /// <summary>
        /// Add % at the end of the string.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string FormatToPercentageValue(this string value)
        {
            return string.Concat(value, "%");
        }
    }
By Anonymous, 2017-12-12 10:58:38
 foreach (Byte bajt in data ) {
                    BufferIndex = i++;
                    if (!char.IsControl((char)bajt))
                        MyCharacter = Convert.ToChar(bajt).ToString();//Encoding.ASCII.GetString(new[]{bajt});
                    else
                        MyCharacter = " ";

                    if (BufferIndex == 200)
                        {
                            int a = BufferIndex;
                        }

                    
                    if (BufferIndex < 200)
                    {
                        sw.WriteLine("PrintBuffer1[" + BufferIndex + "] :=\t" + bajt + "\t; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "\t" + MyCharacter );
                    }

                    if (BufferIndex >= 200 && BufferIndex  < 400)
                    {
                        BufferIndex = BufferIndex - 200;
                        sw.WriteLine("PrintBuffer2[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 400 && BufferIndex < 600)
                    {
                        BufferIndex = BufferIndex - 400;
                        sw.WriteLine("PrintBuffer3[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 600 && BufferIndex < 800)
                    {
                        BufferIndex = BufferIndex - 600;
                        sw.WriteLine("PrintBuffer4[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 800 && BufferIndex < 1000)
                    {
                        BufferIndex = BufferIndex - 800;
                        sw.WriteLine("PrintBuffer5[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1000 && BufferIndex < 1200)
                    {
                        BufferIndex = BufferIndex - 1000;
                        sw.WriteLine("PrintBuffer6[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1200 && BufferIndex < 1400)
                    {
	                        BufferIndex = BufferIndex - 1200;
                        sw.WriteLine("PrintBuffer7[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1400 && BufferIndex < 1600)
                    {
                        BufferIndex = BufferIndex - 1400;
                        sw.WriteLine("PrintBuffer8[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1600 && BufferIndex < 1800)
                    {
                        BufferIndex = BufferIndex - 1600;
                        sw.WriteLine("PrintBuffer9[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1800 && BufferIndex < 2000)
                    {
                        BufferIndex = BufferIndex - 1800;
                        sw.WriteLine("PrintBuffer10[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 2000 && BufferIndex < 2200)
                    {
                        BufferIndex = BufferIndex - 2000;
                        sw.WriteLine("PrintBuffer11[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 2200 && BufferIndex < 2400)
                    {
                        BufferIndex = BufferIndex - 2200;
                        sw.WriteLine("PrintBuffer12[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }

                        
                }

don't repeat yourself.. whyy we don't have PrintBufeer[i] ?

By Anonymous, 2016-02-08 09:52:40
string month = DateTime.Today.Month.ToString();
if (DateTime.Today.Month < 10)
{
    month = "0" + month;
}
string day = DateTime.Today.Day.ToString();
if (DateTime.Today.Day < 10)
{
    day = "0" + day;
}

string dateCorrect = String.Format("{0}.{1}.{2}", DateTime.Today.Year, month, day);

string dateDue = "";
if (transferFields.DueDate.SelectedDate.HasValue)
{
    var dateDuearr = transferFields.DueDate.Value.Split(' ')[0].Split('.');
    dateDue = dateDuearr[2] + '.' + dateDuearr[1] + '.' + dateDuearr[0];
}
else {
    dateDue = dateCorrect;
}

Real developers don't use built in parsing and formatting methods.

By You will be proud of our code!, 2017-12-12 09:53:08
if ((string)filtros[0] != "-1" && (string)filtros[0] != "0") 
    filtros[0] = (string)filtros[0] != "" ? filtros[0] : DBNull.Value;
    
else
    filtros[0] = DBNull.Value;  
By Anonymous, 2020-06-02 18:22:05
if ( variable )
{
    
}
else
{
    Console.WriteLine("Wrong")
}

He doesn't know what "Not" is it :|

By Manoochehr Mojgani, 2017-12-13 17:05:36
try {
    User.ClaimToken();
} 
catch {
    User.ClaimToken();
}
By Anonymous, 2017-12-22 08:44:59
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class StoryOfMyLife : MonoBehaviour
{
    void OnDestory()
    {
        Debug.Log("  Directed by  ");
        Debug.Log("ROBERT B. WEIDE");
    }
}

For Unity developers only

By SanSanych, 2020-09-25 21:22:53
private void reset_kolejnosc()
{
	this.kolejnosc_s[0] = 1;
	this.kolejnosc_s[1] = 2;
	this.kolejnosc_s[2] = 3;
	this.kolejnosc_s[3] = 4;
	this.kolejnosc_s[4] = 5;
	this.kolejnosc_s[5] = 6;
	this.kolejnosc_s[6] = 7;
	this.kolejnosc_s[7] = 8;
	this.kolejnosc_s[8] = 9;
	this.kolejnosc_s[9] = 10;
}
By winek, 2016-07-17 00:16:00
[HttpPost]
[Route("validaPrepacks")]
public IHttpActionResult ValidaPrepacks(ValidaPrepackVO validacion)
{
    try
    {
        return Ok();
    }
    catch (Exception e)
    {
        return Ok(e.Message);
    }

}

A code that "validate" a pack in the backend

By Anonymous, 2019-09-17 21:48:29
public event EventHandler<Cles_graph_doivent_etre_redessines> les_graph_doivent_etre_redessines;
public void remove_event()
{
    if (this.les_graph_doivent_etre_redessines != null)
    {
        foreach (EventHandler<Cles_graph_doivent_etre_redessines> F_les_graph_doivent_etre_redessines in this.les_graph_doivent_etre_redessines.GetInvocationList())
        {
            this.les_graph_doivent_etre_redessines -= F_les_graph_doivent_etre_redessines;
        }
    }
}
By Anonymous, 2015-09-14 05:52:20