Click here to Skip to main content
15,884,472 members
Home / Discussions / C#
   

C#

 
AnswerRe: read value from item array in user control Pin
User 873938131-Jul-14 0:02
User 873938131-Jul-14 0:02 
QuestionComparison Overloading Pin
Rig Maitra25-Jul-14 6:14
Rig Maitra25-Jul-14 6:14 
AnswerRe: Comparison Overloading Pin
Rob Philpott25-Jul-14 6:23
Rob Philpott25-Jul-14 6:23 
GeneralRe: Comparison Overloading Pin
Rig Maitra25-Jul-14 6:29
Rig Maitra25-Jul-14 6:29 
GeneralRe: Comparison Overloading Pin
Rob Philpott25-Jul-14 6:43
Rob Philpott25-Jul-14 6:43 
GeneralRe: Comparison Overloading Pin
OriginalGriff25-Jul-14 8:50
mveOriginalGriff25-Jul-14 8:50 
AnswerRe: Comparison Overloading Pin
KUMAR61928-Jul-14 17:53
professionalKUMAR61928-Jul-14 17:53 
QuestionC# how to compare the old product(serialized) to new product,If same product means add the quantity only not repeated that product in output for below program Pin
Member 1097120125-Jul-14 3:22
Member 1097120125-Jul-14 3:22 
//PRODUCT CODE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication4
{
[Serializable]
public class Product
{
private string ProductID;
private string ProductName;
private float Price;
private int Quantity;

public Product()
{
}

public void Read()
{
Console.WriteLine("Enter Product ID : ");
ProductID = Console.ReadLine();
Console.WriteLine("Enter Product Name : ");
ProductName = Console.ReadLine();
Console.WriteLine("Enter Price : ");
Price = float.Parse(Console.ReadLine());
Console.WriteLine("Enter Quantity : ");
Quantity = int.Parse(Console.ReadLine());
}

public void Show()
{
Console.WriteLine("{0}\t\t{1}\t\t{2}\t\t{3}", ProductID, ProductName, Price, Quantity);
}
}
}

//MAIN PROGRAM CODE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;


namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
List list = new List();
int op;
try
{
Stream stream = File.Open("F:\\Product.obs", FileMode.Open);
BinaryFormatter formatter = new BinaryFormatter();
list = (List)formatter.Deserialize(stream);
}
catch (Exception ex)
{
}
do
{
Console.Clear();
Console.WriteLine("1.New product");
Console.WriteLine("2.List All");
Console.WriteLine("0.Exit");
Console.WriteLine("------------------");
Console.WriteLine("Enter Choice : ");
op = int.Parse(Console.ReadLine());
switch (op)
{
case 1:
Product p = new Product();
p.Read();
list.Add(p);
break;
case 2:
Console.WriteLine("Product Details");
Console.WriteLine("--------------------");
Console.WriteLine("ProductID\t ProductName\t Price\t Quantity");
Console.WriteLine("------------------------------------------");
for (int i = 0; i < list.Count; i++)
{
p = list[i];

p.Show();
}
break;
case 0:
Stream stream = File.Open("F:\\Product.obs", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, list);
break;
}
Console.ReadKey();
}
while (op != 0);
}
}
}
AnswerRe: C# how to compare the old product... Pin
OriginalGriff25-Jul-14 4:35
mveOriginalGriff25-Jul-14 4:35 
QuestionEntity Framework Pin
Steve Foutty25-Jul-14 3:14
Steve Foutty25-Jul-14 3:14 
AnswerRe: Entity Framework Pin
Gerry Schmitz25-Jul-14 11:30
mveGerry Schmitz25-Jul-14 11:30 
GeneralRe: Entity Framework Pin
Steve Foutty25-Jul-14 13:46
Steve Foutty25-Jul-14 13:46 
GeneralRe: Entity Framework Pin
Gerry Schmitz25-Jul-14 14:03
mveGerry Schmitz25-Jul-14 14:03 
QuestionList Pin
Steve Foutty24-Jul-14 15:45
Steve Foutty24-Jul-14 15:45 
AnswerRe: List Pin
Rob Philpott24-Jul-14 20:13
Rob Philpott24-Jul-14 20:13 
AnswerRe: List Pin
Mycroft Holmes24-Jul-14 22:26
professionalMycroft Holmes24-Jul-14 22:26 
GeneralRe: List Pin
Rob Philpott24-Jul-14 23:00
Rob Philpott24-Jul-14 23:00 
GeneralRe: List Pin
PIEBALDconsult25-Jul-14 20:24
mvePIEBALDconsult25-Jul-14 20:24 
AnswerRe: List Pin
Dave Kreskowiak25-Jul-14 2:24
mveDave Kreskowiak25-Jul-14 2:24 
GeneralRe: List Pin
Mycroft Holmes25-Jul-14 14:20
professionalMycroft Holmes25-Jul-14 14:20 
GeneralRe: List Pin
Dave Kreskowiak26-Jul-14 3:53
mveDave Kreskowiak26-Jul-14 3:53 
AnswerRe: List Pin
GuyThiebaut25-Jul-14 3:06
professionalGuyThiebaut25-Jul-14 3:06 
GeneralRe: List Pin
Mycroft Holmes25-Jul-14 14:25
professionalMycroft Holmes25-Jul-14 14:25 
GeneralRe: List Pin
GuyThiebaut25-Jul-14 19:18
professionalGuyThiebaut25-Jul-14 19:18 
AnswerRe: List Pin
Steve Foutty25-Jul-14 3:12
Steve Foutty25-Jul-14 3:12 

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.