Click here to Skip to main content
15,921,959 members
Home / Discussions / C#
   

C#

 
AnswerRe: overload operator + Pin
0x3c015-Apr-09 2:28
0x3c015-Apr-09 2:28 
GeneralRe: overload operator + Pin
al3xutzu0015-Apr-09 2:41
al3xutzu0015-Apr-09 2:41 
GeneralRe: overload operator + Pin
0x3c015-Apr-09 3:05
0x3c015-Apr-09 3:05 
GeneralRe: overload operator + Pin
Luc 64801115-Apr-09 3:20
Luc 64801115-Apr-09 3:20 
GeneralRe: overload operator + Pin
OriginalGriff15-Apr-09 4:08
mveOriginalGriff15-Apr-09 4:08 
GeneralRe: overload operator + Pin
DaveyM6915-Apr-09 4:39
professionalDaveyM6915-Apr-09 4:39 
GeneralRe: overload operator + Pin
OriginalGriff15-Apr-09 5:10
mveOriginalGriff15-Apr-09 5:10 
Questionretrieve object multiple return with different types question? Pin
michaellu8815-Apr-09 2:14
michaellu8815-Apr-09 2:14 
i'm new to programming n networking, i like to know more about how bittorrent working. so, recently i start building torrent retriever. i come across this site http://dotnet.org.za/weareu/archive/2007/04/12/decoding-bencoded-streams-in-c.aspx with the following code to decode torrent file. In the (public static object BDecode(BinaryReader reader)). there have four different type return. if i called this method, how to retrieve the four different variable. thanks.




public class BEncoding
{
public static object BDecode(string filePath)
{
byte[] data = File.ReadAllBytes(filePath);
return BDecode(data);
}

public static object BDecode(Stream stream)
{
if (!stream.CanSeek)
{
throw new Exception("Your stream needs to support seeking for this algorithm");
}

BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.ASCII);
return BDecode(reader);
}

public static object BDecode(byte[] data)
{
return BDecode(new MemoryStream(data));
}

public static object BDecode(BinaryReader reader)
{
char ch = reader.ReadChar();
Int64 ires = 0;
if (ch == 'd')
{
ch = (char)reader.PeekChar();
Hashtable hash = new Hashtable();
while (ch != 'e')
{
object key = BDecode(reader);
hash[key] = BDecode(reader);
ch = (char)reader.PeekChar();
}
return hash;
}
else if (ch == 'l')
{
ch = (char)reader.PeekChar();
ArrayList list = new ArrayList();
while (ch != 'e')
{
list.Add(BDecode(reader));
ch = (char)reader.PeekChar();
}
return list;
}
else if (ch == 'i')
{
ch = reader.ReadChar();
string number = "";
while (ch != 'e')
{
number += ch;
ch = reader.ReadChar();
}
return Int64.Parse(number);
}
else if (Int64.TryParse(ch.ToString(), out ires))
{
string number = "";
while (Int64.TryParse(ch.ToString(), out ires))
{
number += ch;
ch = reader.ReadChar();
}
string line = "";
for (int i = 0; i < Int64.Parse(number); i++)
{
line += reader.ReadChar();
}
return line;
}

throw (new Exception("Torrent Error"));
}
}
AnswerRe: retrieve object multiple return with different types question? Pin
0x3c015-Apr-09 2:24
0x3c015-Apr-09 2:24 
GeneralRe: retrieve object multiple return with different types question? Pin
michaellu8815-Apr-09 15:14
michaellu8815-Apr-09 15:14 
Questionjoin Pin
sheemap15-Apr-09 1:40
sheemap15-Apr-09 1:40 
GeneralRe: join Pin
Pete O'Hanlon15-Apr-09 1:43
mvePete O'Hanlon15-Apr-09 1:43 
GeneralRe: join Pin
sheemap15-Apr-09 1:47
sheemap15-Apr-09 1:47 
GeneralRe: join Pin
Luc 64801115-Apr-09 2:02
Luc 64801115-Apr-09 2:02 
GeneralRe: join Pin
EliottA15-Apr-09 3:13
EliottA15-Apr-09 3:13 
GeneralRe: join Pin
0x3c015-Apr-09 4:30
0x3c015-Apr-09 4:30 
RantRe: join Pin
musefan15-Apr-09 2:34
musefan15-Apr-09 2:34 
AnswerRe: join Pin
tom57200715-Apr-09 2:53
tom57200715-Apr-09 2:53 
Questionproblem in setting backround image to a form created using OpenGL in c# Pin
raesa15-Apr-09 1:34
raesa15-Apr-09 1:34 
Questionhow to write string in PDF Pin
wasimsharp15-Apr-09 1:10
wasimsharp15-Apr-09 1:10 
AnswerRe: how to write string in PDF Pin
stancrm15-Apr-09 1:18
stancrm15-Apr-09 1:18 
GeneralRe: how to write string in PDF Pin
wasimsharp15-Apr-09 18:23
wasimsharp15-Apr-09 18:23 
AnswerRe: how to write string in PDF Pin
tom57200715-Apr-09 2:56
tom57200715-Apr-09 2:56 
Questionmultithreading: lock (static) function library Pin
rpm820015-Apr-09 0:58
rpm820015-Apr-09 0:58 
AnswerRe: multithreading: lock (static) function library Pin
Moreno Airoldi15-Apr-09 3:22
Moreno Airoldi15-Apr-09 3:22 

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.