Implementing IConvertible Interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Memory_understanding
{

    /// <summary>
    /// understanding the reflection property.
    /// </summary>
    class person : IConvertible
    {
        private int roll_number;
        private string name;
        private double marks;

        public int Roll_number { get; set; }
        public string Name { get; set; }
        public double Marks { get; set; }

        public void display()
        {
            Console.WriteLine("Student : " + Name + " Roll No " + Roll_number);

        }
        public void display2()
        {
            Console.WriteLine("This isto understand the reflection property");

        }

        public TypeCode GetTypeCode()
        {
            throw new NotImplementedException();
        }
        public bool ToBoolean(IFormatProvider provider) { throw new NotImplementedException(); }
        public byte ToByte(IFormatProvider provider) { throw new NotImplementedException(); }
        public char ToChar(IFormatProvider provider) { throw new NotImplementedException(); }
        public DateTime ToDateTime(IFormatProvider provider) { throw new NotImplementedException(); }
        public decimal ToDecimal(IFormatProvider provider) { throw new NotImplementedException(); }
        public double ToDouble(IFormatProvider provider) { return Marks; }
        public short ToInt16(IFormatProvider provider) { throw new NotImplementedException(); }
        public int ToInt32(IFormatProvider provider) { return Roll_number; }
        public long ToInt64(IFormatProvider provider) { throw new NotImplementedException(); }
        public sbyte ToSByte(IFormatProvider provider) { throw new NotImplementedException(); }
        public float ToSingle(IFormatProvider provider) { throw new NotImplementedException(); }
        public string ToString(IFormatProvider provider) { return Name; }
        public object ToType(Type conversionType, IFormatProvider provider) { throw new NotImplementedException(); }
        public ushort ToUInt16(IFormatProvider provider) { throw new NotImplementedException(); }
        public uint ToUInt32(IFormatProvider provider) { throw new NotImplementedException(); }
        public ulong ToUInt64(IFormatProvider provider) { throw new NotImplementedException(); }

       


    }
    class program
    {
        public static void Main(string[] args)
        {
            person p = new person();
            p.Marks = 34.5;
            p.Name = "Rohan";
            p.Roll_number = 21;

            int number = Convert.ToInt32(p);
            Console.WriteLine(number);
            Console.ReadLine();
           

        }
    }

}

Comments

Popular posts from this blog

Authentication and Authorization in Web API -Part1

My Gardening Journey 6