Converting a Number in Another Base to Base10

image_pdfimage_print

   
 

using System;
using System.Data;


class Class1{
        static void Main(string[] args){
      string base2 = "111";
      string base8 = "117";
      string base10 = "1110";
      string base16 = "11F1FF";

      Console.WriteLine("Convert.ToInt32(base2, 2) = " + 
        Convert.ToInt32(base2, 2));

      Console.WriteLine("Convert.ToInt32(base8, 8) = " + 
        Convert.ToInt32(base8, 8));

      Console.WriteLine("Convert.ToInt32(base10, 10) = " + 
        Convert.ToInt32(base10, 10));

      Console.WriteLine("Convert.ToInt32(base16, 16) = " + 
        Convert.ToInt32(base16, 16));
        }
}

           
         
     


Converting Radians to Degrees

image_pdfimage_print

   
 

using System;
using System.Data;


class Class1{
        static void Main(string[] args){
            Console.WriteLine(ConvertRadiansToDegrees (2));

            Console.WriteLine(ConvertRadiansToDegrees (3.1415));

            Console.WriteLine(ConvertRadiansToDegrees (0));

        }
    public static double ConvertRadiansToDegrees(double radians)
    {
      double degrees = (180 / Math.PI) * radians;
      return (degrees);
    }
}

           
         
     


Converting Radians to Degrees

image_pdfimage_print

   
 

using System;
using System.Data;


class Class1{
        static void Main(string[] args){
            Console.WriteLine(ConvertRadiansToDegrees (2));

            Console.WriteLine(ConvertRadiansToDegrees (3.1415));

            Console.WriteLine(ConvertRadiansToDegrees (0));

        }
    public static double ConvertRadiansToDegrees(double radians)
    {
      double degrees = (180 / Math.PI) * radians;
      return (degrees);
    }
}

           
         
     


Converting Degrees to Radians

image_pdfimage_print

   
 

using System;
using System.Data;


class Class1{
        static void Main(string[] args){
            Console.WriteLine(ConvertDegreesToRadians (180));

            Console.WriteLine(ConvertDegreesToRadians (90));

            Console.WriteLine(ConvertDegreesToRadians (30));

        }
    public static double ConvertDegreesToRadians (double degrees)
    {
      double radians = (Math.PI / 180) * degrees;
      return (radians);
    }  
}

           
         
     


Nullable extension: Has Value And Equals

image_pdfimage_print
   
 
//http://arolibraries.codeplex.com/
//The MIT License (MIT)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AroLibraries.ExtensionMethods
{
    public static class NullableExt
    {

        public static bool Ext_HasValueAndEquals<T>(this Nullable<T> source, T target) where T : struct
        {
            return source.HasValue &amp;&amp; source.Value.Equals(target);
        }

        public static bool Ext_HasValueAndEquals<T>(this Nullable<T> source, Nullable<T> target) where T : struct
        {
            return source.HasValue &amp;&amp; source.Value.Equals(target);
        }

    }
}

   
     


Is it Nullable

image_pdfimage_print
   
 

//Microsoft Public License (Ms-PL)
//http://visualizer.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Redwerb.BizArk.Core.TypeExt
{
    /// <summary>
    /// Provides extension methods for Type.
    /// </summary>
    public static class TypeExt
    {


        public static bool IsNullable(this Type type)
        {
            if (type == null) return false;
            if (!type.IsGenericType) return false;
            if (type.GetGenericTypeDefinition() != typeof(Nullable<>)) return false;
            return true;
        }
   }
}

   
     


Nulllable HasValue

image_pdfimage_print
   
  



using System;
using System.Collections.Generic;
using System.Text;


public class MyTest {
    public static void NullableTest(Nullable<int> intVal1, int intVal2) {
        if (intVal1.HasValue == true)
            Console.WriteLine(intVal1);
        else
            Console.WriteLine("Value1 is NULL");

        if (intVal2 > 0)
            Console.WriteLine(intVal2);
        else
            Console.WriteLine("Value2 is Null?");
    }
}