Click here to Skip to main content
14,740,223 members
Home » Discussions » ASP.NET
   

ASP.NET

 
QuestionHow do I change this code using Inheritance? Pin
Marc Hede12-Dec-19 22:39
MemberMarc Hede12-Dec-19 22:39 
AnswerRe: How do I change this code using Inheritance? Pin
Richard MacCutchan12-Dec-19 23:15
mveRichard MacCutchan12-Dec-19 23:15 
AnswerRe: How do I change this code using Inheritance? Pin
phil.o12-Dec-19 23:23
mvephil.o12-Dec-19 23:23 
GeneralRe: How do I change this code using Inheritance? Pin
Marc Hede12-Dec-19 23:57
MemberMarc Hede12-Dec-19 23:57 
GeneralRe: How do I change this code using Inheritance? Pin
phil.o13-Dec-19 0:26
mvephil.o13-Dec-19 0:26 
GeneralRe: How do I change this code using Inheritance? Pin
Marc Hede13-Dec-19 0:49
MemberMarc Hede13-Dec-19 0:49 
GeneralRe: How do I change this code using Inheritance? Pin
F-ES Sitecore13-Dec-19 0:59
mveF-ES Sitecore13-Dec-19 0:59 
GeneralRe: How do I change this code using Inheritance? Pin
Marc Hede13-Dec-19 1:17
MemberMarc Hede13-Dec-19 1:17 
Ah of course.
Sometimes it surprises me how simple the solution is. I tend to overthink things Big Grin | :-D

The only issue now is that I get a
System.Runtime.Serialization.SerializationException

at
Mykey = (int)info.GetValue("Keynumber", typeof(int));


Do I need to add Keynumber in my other class file?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace Keycard
{
    class Class1
    {
        public static void Main(string[] args)
        {
            Keycard k1 = new Keycard("John", 123);

            Stream stream = File.Open("KeycardData.dat",
                FileMode.Create);

            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(stream, k1);
            stream.Close();

            k1 = null;

            stream = File.Open("KeycardData.dat", FileMode.Open);

            bf = new BinaryFormatter();

            k1 = (Keycard)bf.Deserialize(stream);
            stream.Close();
            Console.WriteLine(k1.ToString());
            Console.ReadLine();
        }

    }
}

GeneralRe: How do I change this code using Inheritance? Pin
phil.o13-Dec-19 1:52
mvephil.o13-Dec-19 1:52 
GeneralRe: How do I change this code using Inheritance? Pin
F-ES Sitecore13-Dec-19 1:54
mveF-ES Sitecore13-Dec-19 1:54 
GeneralRe: How do I change this code using Inheritance? Pin
Richard Deeming13-Dec-19 1:58
mveRichard Deeming13-Dec-19 1:58 
GeneralRe: How do I change this code using Inheritance? Pin
Richard MacCutchan13-Dec-19 1:00
mveRichard MacCutchan13-Dec-19 1:00 
GeneralRe: How do I change this code using Inheritance? Pin
Marc Hede13-Dec-19 1:25
MemberMarc Hede13-Dec-19 1:25 
GeneralRe: How do I change this code using Inheritance? Pin
Richard MacCutchan13-Dec-19 1:44
mveRichard MacCutchan13-Dec-19 1:44 
QuestionHistogram in Asp.net using canvas js Pin
pooja thombare11-Dec-19 21:47
Memberpooja thombare11-Dec-19 21:47 
AnswerRe: Histogram in Asp.net using canvas js Pin
Richard MacCutchan11-Dec-19 22:16
mveRichard MacCutchan11-Dec-19 22:16 
JokeRe: Histogram in Asp.net using canvas js Pin
Richard Deeming12-Dec-19 13:54
mveRichard Deeming12-Dec-19 13:54 
AnswerRe: Histogram in Asp.net using canvas js Pin
phil.o12-Dec-19 0:05
mvephil.o12-Dec-19 0:05 
QuestionI can´t get any output from XML and Binary. Pin
Marc Hede8-Dec-19 4:51
MemberMarc Hede8-Dec-19 4:51 
AnswerRe: I can´t get any output from XML and Binary. Pin
Richard MacCutchan8-Dec-19 6:15
mveRichard MacCutchan8-Dec-19 6:15 
GeneralRe: I can´t get any output from XML and Binary. Pin
Marc Hede8-Dec-19 8:17
MemberMarc Hede8-Dec-19 8:17 
GeneralRe: I can´t get any output from XML and Binary. Pin
Richard MacCutchan8-Dec-19 22:51
mveRichard MacCutchan8-Dec-19 22:51 
QuestionExample Needed Pin
Mycroft Holmes30-Nov-19 13:02
professionalMycroft Holmes30-Nov-19 13:02 
QuestionRe: Example Needed Pin
Maciej Los3-Dec-19 2:53
mveMaciej Los3-Dec-19 2:53 
QuestionProblem with Using Directive Pin
Dawud Ahmad29-Nov-19 18:00
MemberDawud Ahmad29-Nov-19 18:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.