Click here to Skip to main content
14,453,505 members
   

ASP.NET

 
GeneralRe: How do I change this code using Inheritance? Pin
Richard MacCutchan13-Dec-19 1:44
communityengineerRichard 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
communityengineerRichard MacCutchan11-Dec-19 22:16 
JokeRe: Histogram in Asp.net using canvas js Pin
Richard Deeming12-Dec-19 13:54
communityengineerRichard 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
communityengineerRichard 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 
Thanks.
I got the binary working.
With XML I get an error "cannot be serialized because it does not have a parameterless constructor" at this part:
XmlSerializer serializer = new XmlSerializer(typeof(Keycard));


Not sure what to change/add.

This is how the code looks now after creating it inside a console application.

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 d1 = new Keycard("John", 102030);

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

            BinaryFormatter bf = new BinaryFormatter();

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

            d1 = null;

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

            bf = new BinaryFormatter();

            d1 = (Keycard)bf.Deserialize(stream);
            stream.Close();
            Console.WriteLine(d1.ToString());

            XmlSerializer serializer = new XmlSerializer(typeof(Keycard));

            using (TextWriter tw = new StreamWriter(@"C\Brugere\Marc8\source\repos\keycards.xml"))
            {
                serializer.Serialize(tw, d1);
            }

            d1 = null;

            XmlSerializer deserializer = new XmlSerializer(typeof(Keycard));
            TextReader reader = new StreamReader(@"C\Brugere\Marc8\source\repos\keycards.xml");
            object obj = deserializer.Deserialize(reader);
            d1 = (Keycard)obj;
            reader.Close();
            Console.WriteLine(d1.ToString());
        }

    }
}

GeneralRe: I can´t get any output from XML and Binary. Pin
Richard MacCutchan8-Dec-19 22:51
communityengineerRichard MacCutchan8-Dec-19 22:51 
QuestionExample Needed Pin
Mycroft Holmes30-Nov-19 13:02
MemberMycroft 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 
AnswerRe: Problem with Using Directive Pin
phil.o29-Nov-19 23:19
mvephil.o29-Nov-19 23:19 
SuggestionRe: Problem with Using Directive Pin
Richard Deeming3-Dec-19 1:47
communityengineerRichard Deeming3-Dec-19 1:47 
QuestionShould I begin with razor pages or mvc? Pin
Dawud Ahmad29-Nov-19 7:29
MemberDawud Ahmad29-Nov-19 7:29 
AnswerRe: Should I begin with razor pages or mvc? Pin
Richard MacCutchan29-Nov-19 8:27
communityengineerRichard MacCutchan29-Nov-19 8:27 
AnswerRe: Should I begin with razor pages or mvc? Pin
Richard Deeming29-Nov-19 9:01
communityengineerRichard Deeming29-Nov-19 9:01 
QuestionNewbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 1:31
MemberMarc Hede28-Nov-19 1:31 
AnswerRe: Newbie here. Why is my array list not working? Pin
phil.o28-Nov-19 1:41
mvephil.o28-Nov-19 1:41 
AnswerRe: Newbie here. Why is my array list not working? Pin
Richard Deeming28-Nov-19 2:24
communityengineerRichard Deeming28-Nov-19 2:24 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 7:14
MemberMarc Hede28-Nov-19 7:14 
GeneralRe: Newbie here. Why is my array list not working? Pin
Richard Deeming28-Nov-19 7:39
communityengineerRichard Deeming28-Nov-19 7:39 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 10:09
MemberMarc Hede28-Nov-19 10:09 
GeneralRe: Newbie here. Why is my array list not working? Pin
Richard Deeming29-Nov-19 1:34
communityengineerRichard Deeming29-Nov-19 1:34 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede29-Nov-19 4:00
MemberMarc Hede29-Nov-19 4: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.