Converting Radians to Degrees


   
 

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


   
 

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


   
 

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

   
 
//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

   
 

//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

   
  



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?");
    }
}
 
         
     


Nullable int Types

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

class DatabaseReader {
    // Nullable data field.
    public int? numbericValue;
    public bool? boolValue = true;

    // Note the nullable return type. 
    public int? GetIntFromDatabase() { return numbericValue; }

    // Note the nullable return type. 
    public bool? GetBoolFromDatabase() { return boolValue; }
}

class Program {
    static void Main(string[] args) {
        DatabaseReader dr = new DatabaseReader();

        int? i = dr.GetIntFromDatabase();
        if (i.HasValue)
            Console.WriteLine("Value of &#039;i&#039; is: {0}", i);
        else
            Console.WriteLine("Value of &#039;i&#039; is undefined.");

        // Get bool from &#039;database&#039;.
        bool? b = dr.GetBoolFromDatabase();
        if (b != null)
            Console.WriteLine("Value of &#039;b&#039; is: {0}", b);
        else
            Console.WriteLine("Value of &#039;b&#039; is undefined.");

        // If the value from GetIntFromDatabase() is null, 
        // assign local variable to 100.
        int? myData = dr.GetIntFromDatabase() ?? 100;
        Console.WriteLine("Value of myData: {0}", myData);
    }
}