« first day (2353 days earlier)      last day (2596 days later) » 

6:44 AM
If all I have is method stubs and base documentation, and I'm at almost 800 lines, I should probably use partial classes, right?
 
No.
Partial classes are almost never a good solution.
You probably need to break up your class into separate logical classes.
 
Nope.
Well, I mean, technically, I could. However, I don't see much point in having a class that represents no state and has a single method.
 
6:59 AM
There can be many good reasons. If it has a logical scope, you can reuse it somewhere else without exposing the rest of the logic to a different caller.
But if you have 800 lines without even putting in logic, you either a) have too many methods, which can probably be broken up into logical groupinds, or b) way too much documentation.
 
I really don't see many of them being reused, unfortunately. There are about ~110 methods all used for communicating with a client.
About 70% are send methods, and ~25% parse received data.
The other 5% are utility methods that I've been able to think of so far.
 
And they can't be grouped logically? For me, a class with 110 methods is impossible to probably keep in mind.
 
Well, that's why I thought of partial classes.
 
That's not a logical grouping. It's a technical separation.
It's still the same class, only broken up into several files.
Files aren't a logical unit.
 
What kind of logical grouping do you mean? :)
 
7:03 AM
What are those ~70 send methods like?
 
Some are related, but they mostly represent types of actions that the client should carry out.
SendPlayerDied(), SendPlayerRespawned(), SendCreateUnit() - etc.
 
And these actions are probably logically grouped, right? If you have "Get entity X", "Get list of entity Xs", "Update entity X" and "Delete entity X", you can split those into "EntityXManager".
Alternately, refactor your Send method to be a single method that receives the sent entity . SendMessage(new playerRespawneMessage().
The class that contains game logic shouldn't be the same class that contains communications and serialization logic.
 
They're not.
I mean, I've done it like that before - But I was pretty new to C# and OOP in general and I'm not really sure it turned out well.
Okay, I'll give this a shot, actually. Thanks for your input.
 
7:20 AM
You're welcome.
 
I have issues already. xD
 
7:33 AM
if I may ask about a regex, whats the difference between /^\/start\/.+\/end\/$/ and the same without the $ in the end. Basically what I wanted to do is /^ -> starts with /start/ , .+ -> has at least one or more characters between, \/end\/ -> ends with /end/, and doesnt have any other character following
nvm I got it
 
It's regex. Are you sure? :P
 
what do you mean its regex, iknow lol
 
Ah, I was making a joke. I'm not sure if it's just me, but every time I think I've figured regex out, it turns out I haven't.
 
@jhmckimm No, not just you
 
Shit, that was loud. Was listening to music earlier, lol
 
Haha
@AvnerShahar-Kashtan I actually have (potentially) two messaging protocols for this server. I have no clue how I'd manage that with every message being its own class.
 
Better than every message being its own method in one huge class.
 
oh yeah, sorry its my fault I am edgy idiot, that happens to me a lot too
 
The thing is, if it's all in one huge class, I can just do... class MessagingProtocolOne {} and class MessageingProtocolTwo {}, make them implement the same interface, and then use them interchangeably. That was my original plan.
but ofc a 8000+ line class is no good to me which is why I'm here in the first place.
 
The same applies to message classes. Have MessagingProtocolOne and MessagingProtocolTwo both implement SendMessage.
 
7:46 AM
I don't follow.
 
7:57 AM
A quick example of what my code would end up being: pastebin.com/2rjXSAC7
So in the SendMessage method of the Player class, it'd call .UseProtocol(this.myProtocol) on the message object.
Which feels messy because the protocol will never change, at least until the user starts a new session.
 
 
4 hours later…
11:33 AM
should i close StreamWriter/Reader if i close Stream.?
 
 
3 hours later…
2:38 PM
hi all
a question
the above query gives the result fine without problem
but when i get the result in c#
it only prints
not the the result
why?
this is the c# code ...
MessageBox.Show(""+database.CustomSelect("SELECT TRIM(TRAILING '0' FROM avg(nullif(q1, 0))) q1 FROM feedbackresult").Rows[0][0].ToString());
 
Maybe you need to decode the data? stackoverflow.com/questions/1003275/…
 
0
Q: File.WriteAllText only works in debugger

helloI have this bit of code below to write to a file, but for some reason, it only works when I run the code in debug mode. If I run normally, no text is written to file. What am I doing wrong? static class Logger { private static readonly string TxtFile; static Logger() { TxtFile = "file.t...

 
2:56 PM
thanks ...
i solved by changing the order of functions
MessageBox.Show(""+database.CustomSelect("SELECT avg(TRIM(TRAILING '0' FROM nullif(q1, 0))) q1 FROM feedbackresult").Rows[0][0].ToString());
but i dont know what is wrong with the before one.
 
3:22 PM
:p
 
3:55 PM
I would expect SELECT avg(...) to return something numeric. TRIM, on the other hand, should probably return a string (which you might have to decode).
I mean to the database it is a string but when it gets to your C# code it is just a byte array.
 
4:06 PM
drugs
 
What could be wrong File.WriteAllText() not writing to file? New project, old project, other computers. But works in debug?
 
File does not exist? Did you check for errors? Just as a dumb example if you have a directory called "foo" and you try to write to a file called "foo" it will not work.
 
@Brandin No errors. folder and file name are so different.
 
That is just one example. There could be any number of errors. You may have to check.
Maybe there is a hidden folder of the same name, or some other weird error you weren't expecting. Who knows.
 
could be a permission issue
run as admin, and make sure you're not writing to C: root
 
4:21 PM
"Just run as admin" - the reason there are so many Windows-related security issues.
 
When I append to the file and F5 a few times, then print the content to console, I get the actual content of the file. That means file is created.
I'm running as admin
 
Maybe you have to flush the contents.
 
4:42 PM
@Brandin Doesn't work. How came the file shows up when I run the code through debug. :(((((((
 
Did you try flushing the contents? Debug mode probably does away with some optimizations.
 
@Brandin I flushed. Same weirdo.
 
Maybe you have to close the file too.
 
@hello surround the block with a catch-all block, and check if an exception is thrown. Going by the specification of this function, either it's written, or an exception is thrown
 
@milleniumbug No exception thrown... So file is written, also, when I keep appending to the same file, then write out the content, I get file content.
 
4:50 PM
File.WriteAllText overwrites existing files
 
@milleniumbug Yes, I know. When I use File.AppendText I get content.
 
so what, you open the file and theres nothing in it?
 
5:06 PM
43 mins ago, by hello
When I append to the file and F5 a few times, then print the content to console, I get the actual content of the file. That means file is created.
 
How exactly do you verify that the file is not created? Are you sure it is not just created later than you expect ("pressing F5 a few times" is not precisely defined).
I mean the problem sounds like not really a problem. You create it, the data is still there after you "press F5" (I guess in Windows Explorer, because you never said).
 
I think it's pretty clear the file is created, problem is I cant see it. Even after turning Show Hidden files On, run as admin save to desktop, start a new project lol
 
5:28 PM
where do you expect to see it?
in other words, whats your path
from your question, it should be in bin
 
5:50 PM
Maybe it is a problem with Windows Explorer. It does not always show the latest information.
 
i doubt that
 
6:15 PM
Hi guys, how to call a matlab function into a c# project?
 
@SteveG I tried that example already. It doesn't work. The function myfunc is not executed as expected
 
Anti-virus sandbox.
 
want help in UNITY
 
@SteffiKeranRaniJ Say what error you got.
 
6:35 PM
Hollla
a question
why this line of code
string s = String.Format("{#.##}", 1.55555);
shows this error
Input string was not in a correct format
why?
 
@Nitesh Whats the problem?
 
it shows that Exception
Input string was not in a correct format
 
@HamreenAhmad is this on Unity?
 
you mean 3d unity?
 
yes
 
6:46 PM
kidding me??
this is c# room
 
unity3d uses c# too. i saw someone talking about unity above. sorry about that.
 
Try String.Format("{0:#.##}", 1.555555)
The format of the format string is {index[,alignment][: formatString]}
index is not optional.
 
@Brandin
i have this table
so i need to format all its content
i have used this method to format its datatable
public DataTable formatDt(DataTable dt)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (j < 13)
                    {
                        dt.Rows[i][j] = String.Format("{0:#.##}", dt.Rows[i][j].ToString());
                    }
                }
            }
            return dt;
        }
But it shows an Exception and stops Formating when it sees Empty cells
for example Row 1,column 11
 
What do you want to do for empty cells?
 
how to solve that problem?
leave it Empty
it just need an if
i got it thanks
 
6:57 PM
Then maybe if it is empty set dt.Rows[i][j] = ""
 
no
it need
if(dt.rows[i][j].toString()=="")
continue;
OMG still not solved
it dont format it
any problem with the method?
public DataTable formatDt(DataTable dt)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (j < 13)
                    {

                        if (dt.Rows[i][j].ToString() == "")
                            continue;
                        dt.Rows[i][j] = String.Format("{0:#.##}", dt.Rows[i][j].ToString());
                    }
                }
            }
            return dt;
 
7:17 PM
Hi all!
I dont want to post this on StackOverflow, since it isn't such a huge problem.
I would like to change the color of an ellipse, based on an int value. (Bigger than zero red, less or equal to zero green)

So far so good. I made a IntToBooleanConverter, which is just return ((int)value > 0). The xaml looks as follows:

<Ellipse x:Name="ellipse1" Fill="Green" RenderTransformOrigin="0.5,0.5" >
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
I played around with Mode and the NotifyOnSource/Target changed. (As you may see in the given code). TextBlock and Ellipse are in the same DataContext scope.
 
7:30 PM
Problem solved. I am binding directly Fill with a IntToColor converter
 

« first day (2353 days earlier)      last day (2596 days later) »