|
Is Serializable Attribute's behavior inheritable?
i have two classes classA, classB.
classA have Serializable attribute applied to it.
classB inherits classA
i want to serialize classB.
do i have to apply serializable attribute to classB as well, or inherting from classA
would be enough.
thanks.
modified on Sunday, September 7, 2008 9:23 AM
|
|
|
|
|
You can use something like this to test your case:
Stream stream = File.Open("serialized.xml", FileMode.Create);
SoapFormatter formatter = new SoapFormatter();
classB instanceB = new classB();
formatter.Serialize(stream, instanceB);
stream.Close();
|
|
|
|
|
The [Serializable] attribute is not inherited because your derived class might have fields that are not serializable.
The author of your base class (who made the decision to make ClassA serializable) has no idea what you might add to ClassB. So the decision to make a class serializable (or not) is up to the class's author.
Enjoy,
Robert C. Cartaino
|
|
|
|
|
unfortunatly am only able to write a simple program on one form being the parent form.How can I advance and maybe try to use two or more forms.Don't know how to create a new form and how to call it from my main form.Please help.....
|
|
|
|
|
You should really start with learning the basics of C# and programming before visiting a board like this.
To help you get started look at a few of these links[^].
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton I gave up when I couldn't spell "egg". Justine Allen
|
|
|
|
|
you should keep doing that: parent form & child forms.(there´s a great article here about that, don´t remember the link)
search for "transfer data between forms", if you want you will get lot´s of intel, i have downloaded samples of code on it, but i think more on :
parent form & child forms or
1 form & userforms trigger the load of different userforms inside the form.
is there a major reason for many forms?
that´s my advice
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I have a trackbar which i set the minimum to 0, maximam to 100, small and large changes to 20 and frequency to 20 but when the user move the slider he's still able to set to 21 and 22 but i want the value to be 0, 20, 40, 60, 80 or 100?
how can i do that in run time?
|
|
|
|
|
Could you set minimum to 0 and maximum to 5. Then multiply the value by 20 and you'll have
- 0 * 20 = 0
- 1 * 20 = 20
- 2 * 20 = 40
- 3 * 20 = 60
- 4 * 20 = 80
- 5 * 20 = 100
|
|
|
|
|
i need help on this project i need to develop a firewall in C# i have 10 months for this purpose and that firewall should perfrom the following functions
allow traffice
block traffic
ip filtering/mac address filtering
access control list
can create rules
should i work on this project or not i mean i am a new C# guy and dont have that much experience i can only work on SQL database applications but i am ready to work on it with full devotion what is your opinion? please help me to get this done or give me some advice for any other final year project
please refer me some reading material specifically for this firewall development i need to know what C# functions i would be using i mean to say network programming fuctions in C#
thanx
|
|
|
|
|
This sounds like a pretty big task considering your limited experience in C#. I'd recommend that you buy a book on networking in C# to get you started. I also came across an article on packet filtering on CP which might be useful and help get you started.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Firewalls are low level (kernel mode) things and are much better suited to C/C++. I'm not saying it can't be done in C#, but I'm sure you'll end up using mainly unmanaged code which will sort of defeat the purpose of using C#.
Good luck if you do decide to attempt it
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
thank you for your response
keep up your suggestion they will make the things easy for me
is there any reading material that you suggest specifically about firewall and networking in C#
|
|
|
|
|
heres a good book http://tinyurl.com/5zxuyb
good luck!
-Steven
C# Programmer
|
|
|
|
|
I. Overview
1. Create a program that will accept the necessary inputs and generate the proper outputs based on the processing instructions.
2. The program should meet all the requirements.
II. Inputs
1. Employee’s ID Number – an 8 digit integer
1st four digits signifies the year the employee started.
5th digit signifies employment type. 0 for regular, 1 for
contract. Other values are invalid.
Last 3 digits are irrelevant for this program.
2. Salary Grade – a real number
3. Days worked for the month – an integer with valid values of 1 to 31 only.
4. wBonus – a character to signify whether the employee will receive a bonus or not
III. Processing
1. Prompt for all necessary inputs. Check every input for validity.
2. Compute for the employee’s salary for the month.
Basic Salary = Salary grade * Days Worked
For employees with bonus
For regular employees who started before 1990
Bonus = Basic Salary * .4
For regular employees who started before 2000
Bonus = Basic Salary * .3
For regular employees who started before 2006
Bonus = Basic Salary * .2
For regular employees who started after 2005 and contract employees
Bonus = Basic Salary * .1
Salary for the Month = Basic Salary + Bonus
3. Accumulate Total Basic Salary and Total Bonus.
4. Display Employee’s Salary for the Month(output #1)
5. Prompt if the user wants to process another employee. If yes, go back to #1.
6. Display Total Basic Salary and Total Bonus(output #2)
IV. Outputs (use 2 decimal places for real numbers)
1. ID Number and Salary for the Month. Example:
ID Number: 19970123 Salary: P1500.50
2. Total Basic Salary and Total Bonus. Example:
Tot Basic Salary: P180,000.90 Tot Bonus: P20,000.55
V. Requirements
1. Use the printf function for all outputs including prompts.
2. Use the scanf function for accepting/reading all inputs.
3. Use defined constants for the constants used in the bonus computation.
4. Declare/define functions for each routine/subroutine in the program.
5. Use error checking. If the user inputs an invalid value, inform the user and prompt for a new value.
6. Users should be able to use the program without special instructions or training.
bleh
|
|
|
|
|
So.. what's your question?
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
It soesn't look too difficult.
It's already broken down into sections so deal with each one individually.
I'd leave the validation until last - get it working first.
Enjoy coding, and post back if you have any specific problems relating to your code when you've written some.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
What is it that you need help with?
Don't you understand the instructions? They seem very clear to me.
Judging from the contents of the instructions, you have posted in the wrong forum. This forum is for C# programming, not C/C++ programming.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
So what code have you written so far?
Kevin
|
|
|
|
|
I suggest changing majors now.
Blog link to be reinstated at a later date.
|
|
|
|
|
i hope you are not asking anyone to type the all program for you!?
whats your question?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
This is why I feel secure in my job. Schools full of students who are obviously too dumb to do IT, and too dumb to know it.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hello all,
I am currently developing a application on windows mobile that can receive video image from webcam via a desktop. Here is my code:
namespace ABC
{
public partial class Form1 : Form
{
// private System.Net.IPHostEntry ips = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
//---port nos and server IP address---
const Int32 PORTNO = 500;
string server_IP = "10.0.1.200";
//---size of the video image---
const int SIZEOFIMAGE = 341504;
//---use for connecting to the server---
TcpClient client;
//--used for sending and receiving data---
byte[] data;
//---used for receiving images from the server---
System.Threading.Thread t;
private void ReceiveImageLoop()
{
//---keep on receiving image until an error occurs---
while (ReceiveImage())
{
MessageBox.Show("in receive image");
}
//---display error message---
MessageBox.Show("Server has stopped responding. Please try restarting the video.");
}
//---Sends a message to the server---
private void SendMessage(string message)
{
//---adds a carriage return char---
message += "\n";
try
{
//---send the text
System.Net.Sockets.NetworkStream ns = null;
lock (client.GetStream())
{
ns = client.GetStream();
byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message);
//---sends the text---
ns.Write(bytesToSend, 0, bytesToSend.Length);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//---receive video image from server---
public bool ReceiveImage()
{
MemoryStream s = new MemoryStream();
NetworkStream nws = client.GetStream();
int counter = 0;
int totalBytes = 0;
do
{
MessageBox.Show("trying to read data...");
//---read the incoming data---
int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize); totalBytes += bytesRead;
//---write the byte() array into the memory stream---
s.Write(data, 0, bytesRead);
counter += 1;
//Loop Until totalBytes >= SIZEOFIMAGE
} while ( ! (totalBytes >= SIZEOFIMAGE));
//---display the image in the PictureBox control---
PictureBox1.Image = new Bitmap(s);
//---ask the server to send the next image---
SendMessage("Send");
return true;
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (((Button)sender).Text == "Start")
{
//---connect to the server---
client = new TcpClient();
client.Connect(server_IP, PORTNO);
data = new byte [client.ReceiveBufferSize];
//---send message---
SendMessage("Send");
//---begin reading data asynchronously from the server---
t = new System.Threading.Thread(ReceiveImageLoop);
t.Start();
}
else
{
//---send message---
SendMessage("Stop");
t.Abort();
}
}
}
}
-------------
I keep on getting error message saying IOException for the code of lines highlighted in Bold. I have no idea why I am getting this as for my Windows version of the code, it is working smoothly.
Here are the details of the exception:
System.IO.IOException was unhandled
Message="An error message cannot be displayed because an optional resource assembly containing it cannot be found"
StackTrace:
at System.Net.Sockets.NetworkStream.Read()
at FYP.Form1.ReceiveImage()
at FYP.Form1.ReceiveImageLoop()
.
Help/suggetions from anyone will be highly apprecaited ! thanks !
|
|
|
|
|
add
data = new byte[client.ReceiveBufferSize]; before bold line
hope it helps
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Hi Mbah,
I am still getting an error after inserting your line.
Any more suggestions ?
Thanks !
|
|
|
|
|
do
{
if (nws.DataAvailable){
int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize);
totalBytes += bytesRead;
s.Write(data, 0, bytesRead);
counter += 1;
}
} while ( ! (totalBytes >= SIZEOFIMAGE));
hope it helps
dhaim
programming is a hobby that make some money as side effect
|
|
|
|