Post: [C#] Usefull stream functions
09-26-2011, 05:30 AM #1
Woof
...hmm
(adsbygoogle = window.adsbygoogle || []).push({});
Hello,
just thought I would share a little something with you.
Enzo

The first script will read and return the chars till it hits the argumented char.

script:
    
public char[] readTillChar(BinaryReader stream, int start, char tillchar)
{
int size = Convert.ToInt16(stream.BaseStream.Length);
char[] chars = { };
for (int i = start; i < size; i++)
{
char readchar = stream.ReadChar();
if (readchar == tillchar)
return chars;
else
chars[i] += readchar;
}
return chars;
}

How to use:
    
char[] chars = readTillChar(reader, 0, '\xFF'Winky Winky;


The next script returns the place of the argumented char via int.

Script:
    
public int getCharplace(BinaryReader stream, char find)
{
int size = Convert.ToInt16(stream.BaseStream.Length);
int counter = 0;
for (int i = 0; i < size; i++)
{
char readchar = stream.ReadChar();
if (readchar != find)
counter += 1;
else
return counter;
}
return counter;
}


How to use:
    
int where = getCharplace(reader,'\x00'Winky Winky;


So there you go, simple scripts I use very much in most of my data handling. =]
(adsbygoogle = window.adsbygoogle || []).push({});
09-26-2011, 07:31 PM #11
Woof
...hmm
Originally posted by AsianInvasion View Post
I never said I disliked your method, I even said, in my original post, that I do not have any complaints. Furthermore, I'm not trying to start an argument, or even cause any form of conflict.

I was just curious as to when you would use this in a majority of your data handling, and it seems my curiosity has uncovered something of a logical fallacy. But, I mean this as no offense towards you.

Im not offended, your just annoying me.
09-26-2011, 07:35 PM #12
Epic?
Awe-Inspiring
Originally posted by BAdmaNgLiTcHa View Post
Im not offended, your just annoying me.

How am I annoying you? I merely inquired on a topic that concerned me, which then uncovered a flaw in your statement.
09-26-2011, 07:39 PM #13
Woof
...hmm
Originally posted by AsianInvasion View Post
How am I annoying you? I merely inquired on a topic that concerned me, which then uncovered a flaw in your statement.

There is no flaw?, I do use it for data handling...

The following user thanked Woof for this useful post:

09-26-2011, 09:32 PM #14
Epic?
Awe-Inspiring
Originally posted by BAdmaNgLiTcHa View Post
There is no flaw?, I do use it for data handling...


The flaw is that you claim to use it in a majority of data handling, however, these aren't particularly useful with the exception of a couple, rare situations. Even at that, there are typically better ways to take in and parse data.
09-27-2011, 12:07 AM #15
Pichu
RIP PICHU.
Originally posted by AsianInvasion View Post
I never said I disliked your method, I even said, in my original post, that I do not have any complaints. Furthermore, I'm not trying to start an argument, or even cause any form of conflict.

I was just curious as to when you would use this in a majority of your data handling, and it seems my curiosity has uncovered something of a logical fallacy. But, I mean this as no offense towards you.


I get what you are trying to say and I have to agree. Someone could possibly just expand off of this or alter it then expand to fit their own purposes. You never know what these could be used for when it comes to all the imaginative people in the world.

The following user thanked Pichu for this useful post:

Epic?
09-27-2011, 02:54 AM #16
Woof
...hmm
Originally posted by AsianInvasion View Post
The flaw is that you claim to use it in a majority of data handling, however, these aren't particularly useful with the exception of a couple, rare situations. Even at that, there are typically better ways to take in and parse data.


Originally posted by Sublimity View Post
I get what you are trying to say and I have to agree. Someone could possibly just expand off of this or alter it then expand to fit their own purposes. You never know what these could be used for when it comes to all the imaginative people in the world.


You both are making no sence, your acting as I have posted these for data handling, i posted them to stream files like it says above.
I do use it for simple data handling, mostly for small things, like maybe saving last uses settings etc.
Programming is full of many methods, everybody has there own method, therefor you guys saying its not for data handling makes no sence, i use these when I do my raw file streaming to get certain points of a file, I use them for data handling but I obviously have more to it.
Let me just show you how I use it, its best use is for small data storage files.
Take a look at this...
You must login or register to view this content.
Thats what my databases look like, very optimized and very simple.
Winky Winky
09-27-2011, 03:00 AM #17
Pichu
RIP PICHU.
Originally posted by BAdmaNgLiTcHa View Post
You both are making no sence, your acting as I have posted these for data handling, i posted them to stream files like it says above.
I do use it for simple data handling, mostly for small things, like maybe saving last uses settings etc.
Programming is full of many methods, everybody has there own method, therefor you guys saying its not for data handling makes no sence, i use these when I do my raw file streaming to get certain points of a file, I use them for data handling but I obviously have more to it.
Let me just show you how I use it, its best use is for small data storage files.
Take a look at this...
You must login or register to view this content.
Thats what my databases look like, very optimized and very simple.
Winky Winky


Alright. Well if you read what I said, someone could use what you put and expand on it. Yes we all have our own methods of doing things, some easier than others.

I understand where Asian is getting at and I get what you are getting at. :/

All I am going to say.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo