nkn - suniladhya/Advantage GitHub Wiki

Sapiens(Online) Talisman(Excellent Basic Interview) PWC(Excellent Advance oops)

when to choose which sort method http://courses.cs.vt.edu/~cs3114/Summer10/Notes/T12.SortingAlgorithms.pdf

prevent hijacking a cookie using javascript https://docs.microsoft.com/en-us/dotnet/api/system.web.httpcookie.httponly?view=netframework-4.7.2

threading model in ASP.NET\using System; using System.Collections.Generic; using System.Linq; using System.Text;

public class Test : ITest { public Boolean IsAnagram(String first,String second) {
bool isAnagram = false;

    char[] charArr1 = first.ToLower().ToCharArray();  
    char[] charArr2 = second.ToLower().ToCharArray(); 

    string str1 = new string(charArr1);  
    string str2 = new string(charArr2);

    if(str1 == str2)
    {
        isAnagram= true;
    }
    
return isAnagram;
}

}

class Program { static void Main(string[] args) { List

figureList = new List();
    Figure rectangle = new Figure()
    {
        Height = 3,
        Width = 4,
        Type = ShapeType.Rectangle
    };
    figureList.Add(rectangle);

    Figure square = new Figure()
    {
        Type = ShapeType.Square,
        Height = 4,
        Width = 4
    };
    figureList.Add(square);

    Figure circle = new Figure()
    {
        Type = ShapeType.Circle,
        Radius = 3.5
    };
    figureList.Add(circle);

    foreach (Figure figure in figureList)
    {
        Console.WriteLine(figure.CalculateArea());
        figure.Save();
    }

}

}

public class Figure { public double Height { get; set; } public double Width { get; set; }

public double Radius { get; set; }

public ShapeType Type { get; set; }

public void Save()
{
    if (Type == ShapeType.Circle)
        throw new Exception("Circle cannot be saved!");

    //save the object to a file
    using (Stream stream = File.Open("saveFile.bin", FileMode.OpenOrCreate))
    {
        BinaryFormatter formatter = new BinaryFormatter();
        formatter.Serialize(stream, this);
    }
}

public double CalculateArea()
{
    try
    {
        if (Type == ShapeType.Rectangle)
        {
            return Height * Width;
        }
        else if (Type == ShapeType.Square)
        {
            return Height * Height;
        }
        else if (Type == ShapeType.Circle)
        {
            return Radius * Radius * Math.PI;
        }
    }
    catch (Exception e)
    {
        if (e is ArgumentNullException)
        {
            //log to a file
            System.IO.File.WriteAllText("log.txt", e.ToString());
        }
        else if (e is ArgumentException)
        {
            //log to console
            Console.WriteLine(e.ToString());
        }
    }

    return 0;
}

}

public enum ShapeType { Rectangle, Circle, Square }

⚠️ **GitHub.com Fallback** ⚠️