TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
srinivas reddy
NA
90
0
how can i add these 3 records to SortedList
Dec 24 2009 1:26 AM
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
SortedListDemo
{
class
Sorted_List
{
int
id, marks;
string
name;
public
Sorted_List(
int
id,
string
name,
int
marks)
{
this
.id = id;
this
.name = name;
this
.marks = marks;
}
public
override
string
ToString()
{
return
String
.Format(
"id: {0,-5} name: {1,-5} marks : { 2}"
,id,name,marks);
}
}
class
SortedList1
{
static
void
Main(
string
[] args)
{
SortedList
<
Sorted_List
,
int
> sobj =
new
SortedList
<
Sorted_List
,
int
>();
Sorted_List
s =
new
Sorted_List
(1,
"hello"
, 34);
Sorted_List
s1 =
new
Sorted_List
(20,
"world"
, 32);
Sorted_List
s2 =
new
Sorted_List
(0,
"hai"
, 98);
//here not adding the records,giving string format exception
sobj.Add(s, 3);
sobj.Add(s1, 0);
sobj.Add(s2, 1);
foreach
(
KeyValuePair
<
Sorted_List
,
int
> s4
in
sobj)
{
Console
.WriteLine(s4);
}
}
}
Reply
Answers (
3
)
what is the diference between LinkedList and SotedLis
Dictionaries