Click here to Skip to main content
15,790,440 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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
pooja 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
professionalphil.o12-Dec-19 0:05 
QuestionI can´t get any output from XML and Binary. Pin
Marc Hede8-Dec-19 4:51
Marc 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
Marc 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:
C#
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.

C#
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
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
Dawud Ahmad29-Nov-19 18:00 
AnswerRe: Problem with Using Directive Pin
phil.o29-Nov-19 23:19
professionalphil.o29-Nov-19 23:19 
SuggestionRe: Problem with Using Directive Pin
Richard Deeming3-Dec-19 1:47
mveRichard Deeming3-Dec-19 1:47 
QuestionShould I begin with razor pages or mvc? Pin
Dawud Ahmad29-Nov-19 7:29
Dawud Ahmad29-Nov-19 7:29 
AnswerRe: Should I begin with razor pages or mvc? Pin
Richard MacCutchan29-Nov-19 8:27
mveRichard MacCutchan29-Nov-19 8:27 
AnswerRe: Should I begin with razor pages or mvc? Pin
Richard Deeming29-Nov-19 9:01
mveRichard Deeming29-Nov-19 9:01 
QuestionNewbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 1:31
Marc Hede28-Nov-19 1:31 
AnswerRe: Newbie here. Why is my array list not working? Pin
phil.o28-Nov-19 1:41
professionalphil.o28-Nov-19 1:41 
AnswerRe: Newbie here. Why is my array list not working? Pin
Richard Deeming28-Nov-19 2:24
mveRichard Deeming28-Nov-19 2:24 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 7:14
Marc Hede28-Nov-19 7:14 
GeneralRe: Newbie here. Why is my array list not working? Pin
Richard Deeming28-Nov-19 7:39
mveRichard Deeming28-Nov-19 7:39 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede28-Nov-19 10:09
Marc Hede28-Nov-19 10:09 
GeneralRe: Newbie here. Why is my array list not working? Pin
Richard Deeming29-Nov-19 1:34
mveRichard Deeming29-Nov-19 1:34 
GeneralRe: Newbie here. Why is my array list not working? Pin
Marc Hede29-Nov-19 4:00
Marc 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.