« first day (1379 days earlier)      last day (3569 days later) » 

2:06 AM
Hi
If anyone's on, what's the best way to continuously loop something?
Like, every 30 seconds do something. I find that using Thread.Sleep actually takes more CPU to process?
 
 
2 hours later…
4:00 AM
@Daaksin take a Timer object
 
4:20 AM
morning
 
4:46 AM
morning
 
5:14 AM
Anyone used Win32.OpenFileDialog on Windows 8.1? I am using it to select files that do not have an association and it keeps popping up that stupid dialog asking how I want to open the file. I only want to return the filename to my WPF application (which it does) but it also seems to want to open the file too.
 
 
1 hour later…
6:24 AM
morning guys
 
6:43 AM
What time is it where you are?8:43PM here
 
7:33 AM
Hi guys !
in Linq if i am using a linq query (i.e. from .....) not Lambda expressions.. then how could i use Take in that ?
 
7:54 AM
@CodeWarrior was the time question directed to me?
 
 
1 hour later…
9:14 AM
@GotalovePHP Yeah, but it is no big deal. Was just curious.
 
oh okay its 12.23pm now
 
 
1 hour later…
10:35 AM
posted on July 25, 2014 by jonskeet

As some of you have noticed (and let me know), my old blog hosting provider recently moved off Community Server to WordPress. I figured that as all the links we being broken anyway, now would be a good time to move off msmvps.com anyway. The old posts are still there, but my blog’s new home […]

 
 
3 hours later…
1:48 PM
If LINQ was the gateway drug to functional programming for C# devs, Rx is the Crack.
 
2:18 PM
Which is why C# is better than Java
MS have MS Research, who listen to smart people about how programming should be done, and implement novel language features because they reflect the state of the art
 
did you stop watching?
 
paused
 
I need a beach break
 
2:34 PM
@TomW how far did you make it?
 
up to the bit about agents
and oh look, it's a message bus
again
 
I'm gonna watch the rx course, used it without knowing much about it
 
You have a problem. "I know", you say, "I'll use asynchronous message passing". Soon you'll have two problems.
^ make funnier plz
 
 
2 hours later…
4:57 PM
hello guys i have a string like this:
string str = "c5";
and i need to convert it like:
int x = 0xc5;
string to hex
can someone help me?
 
5:19 PM
int x = int.Parse(str, System.Globalization.NumberStyles.HexNumber);
 
The description of this room seems, pleasant.
 
@JohanLarsson i tried and istead of 0xc5 it outputting 197
i need to get it with the prefix too
into an integer
 
5:37 PM
you want "c5" -> "0xc5"?
 
yes
c5 (string) -> 0xc5 (int)
 
int will always be 197 (same thing)
 
so
int x = 0xc5
is equal with
int x = 197
?
 
hmm ok
 
5:41 PM
<- check history
 
@JohanLarsson hmm but i still need to have an integer with that string parsed in it and before it the prefixe "0x"
if string is "c5" i need an integer like: 0xc5
 
I'm a bit busy, try googling for a while
 
0xc5 is 197
 
@JohanLarsson sorry
@TomW i know but i need to get it parsed from the string exactly how it is and with the prefixe before it
 
no need for sorry, how could you possibly know?
 
5:54 PM
'exactly how it is'
what?
Explain why what you're getting isn't what you expected
 
user1804599
@KraziiKiiD Look up the difference between value and representation.
 
user1804599
0xc5 and 197 are two different representations for the same value.
 
user1804599
Integers store values and don’t give a shit about representation.
 
user1804599
Representation is purely a serialisation thing.
 
yes but if i have a string like this:
string str = "c5";
 
user1804599
5:57 PM
That is a string that could represent an integer in hexadecimal notation.
 
i just want to be able to create an integer like:
int str1 = 0xc5;
 
user1804599
1 min ago, by rightfold
Integers store values and don’t give a shit about representation.
 
from that string
with the prefixe
 
Listen to what you're being told. They're the same.
 
@rightfold yes but by me i need to do like that..
 
5:58 PM
That's what an integer is
 
user1804599
@KraziiKiiD Then use a language that is terrible by mixing up value and representation, instead of C#.
 
okay then.
 
user1804599
Or store in a separate value the way you want the integer to be serialised, and use that during serialisation.
 
user1804599
For example:
 
user1804599
var str = "c5";
bool isHex = detectBase(str);
int i = isHex ? int.Parse(str, System.Globalization.NumberStyles.HexNumber) : int.Parse(str);
// later
if (isHex) {
    // ...
} else {
    // ...
}
 
user1804599
6:01 PM
FYI that is pseudocode.
 
ok..
then
if i had in my code something like:
if (x == 0xc5)
where x is integer
i can put
 
user1804599
@RoelvanUden $ twitter timeline | sed 's/#//g' :D
 
if (x == 197)
?
 
user1804599
Of course.
 
user1804599
0xc5 and 197 are exactly the same thing.
 
user1804599
6:02 PM
They just look different.
 
in my code doesnt seems, but whatever, thanks.
 
6:32 PM
but guys my code is like this:
if (data[start + 1] == 0xc5)
data is byte[]
 
you can't fit 197 in a byte
 
and i can't put instead of 0xc5 -> 197
i know so what should i do?
 
It's your code, you tell me?
What are you trying to do?
 
im reading somethinf rom memory it works but
i in my code
if (data[start + 1] == 0xc5
it gaves me true
but when i put instead of
197
0xc5
 
Whole sentences, please
 
6:35 PM
it says false
so they aren't the same
can you help me ?
 
I guess it's something to do with what the hex literal gets implicitly typed as - my guess is that the compiler is interpreting the left side as a byte and truncating it, whereas 197 can only be interpreted as an int
I'm going to try it myself
 
i think you're right
 
wait, what am I saying
TOTAL brainfart. Of course 197 is within the allowed values of a byte.
 
197 < 255
but in that byte array why i can find 0xc5 and 197 no ?
 
I've just written a demo that says they give the same answer
static void Main(string[] args)
{
    byte[] data = { 0xc5 };
    var isbyte = (data[0] == 0xc5);
    var isInt = (data[0] == 197);
    //both are true
}
 
6:41 PM
no way
 
Do you agree that is doing the same thing?
 
yes but by me no
 
obviously the code is not quite the same, but there's a byte array with a value in it that you compare to a literal
 
@KraziiKiiD you need to show some code =]
there is something weird going on
 
0xc5 is hex and 197 decimal
@drch i wrote it like i said here
 
6:43 PM
I guarantee to you that they represent the same number
 
@KraziiKiiD so did tom, and his works. show your code that isn't working. something else is going on
 
:17932229 if (data[start + 1] == 108 && data[start + 2] == 130)
                            {
                                Key = data.Skip(start).Take(32).ToArray();
                            }
 
oh sorry
 
108 and 130 is 0x6c and 0x82
 
btw, .ToArray() is going to make a new array
 
6:44 PM
they are false like this
leave out that Key thing
 
so editing stuff in that Key will not affect the stuff in data
 
just the if statements
 
ok
 
so they are false with 108 and 130
but true with 0x6c and 0x82
why ? :(((
 
and data is a byte[] ?
 
6:46 PM
yes
 
@KraziiKiiD unit tests are pretty nice for playing around with stuff like this
 
        byte[] data = new byte[3] { 0, 108, 130 };
        int start = 0;
        if (data[start + 1] == 0x6c && data[start + 2] == 0x82)
        {
            Console.WriteLine("yep");
        }
works fine for me
 
The way you've described the problem, I don't believe you
 
is this in a lambda or something?
 
i have written like this too
but by me are false with decimal value
 
6:50 PM
compiler bug then, nothing to do
 
:P
@KraziiKiiD if you copy that code that i or tom wrote, do you still get the same error?
 
yes
 
wtf
 
its krazy
 
Compiler error? Always intrigued. What is the question/problem?
 
6:51 PM
also - what is the compiler :P
 
@LasseV.Karlsen it was a joke
 
@LasseV.Karlsen do you have some sort of script alerting you to that phrase? Amusing that you suddenly became active at that moment :P
 
@KraziiKiiD did you actually put that code into a program? or are you just comparing it in your head and saying its similar.
 
guys
 
Script? I'm omnipotent. You should know that by now.
 
6:53 PM
@drch putted
 
I always appear when you least expect it.
 
but if data[start] == 0xc5
is true
and with 108 false
is there a way to convert from 108 into 0xc5 ?
with the prefixe too
?!
 
no because they are the same thing
 
god
 
108!=0xc5
 
6:54 PM
there is no "conversion"
 
uhm, what do you mean by convert from 108 to 0xc5? What base is this?
 
108 is 0xc6
 
So how do you want the conversion to work then?
 
no, it's not
 
ie. how can 108 become c5?
 
6:54 PM
allright so:
 
c6 is 198
 
with or without the prefix
 
@KraziiKiiD 6C
 
0xc6 is 108 :|
 
no it is not
check it?
 
6:55 PM
looks like you got your numbers mixed up? you were saying before 197
 
108 is 0x6c (opposite digits)
 
use windows calculator, that does the conversion
 
sorry is 6C :|
allright allright sorry
 
So how can 108 become c5
 
so then i want to convert from a decimal to hex with the prefix too
and the result should be an integer
 
6:56 PM
what is the data type of the variable containing the number
 
thats not how computers work
the data is the data
how its formatted is just output
 
string str = "6c12345";
 
?
 
var x = 108;
var s = x.ToString("x2"); // 6c
 
int x = int.Parse(str.Substring(0, 2));
 
6:57 PM
, 16
sorry, that was a different method
 
ok so i have
int x = 108;
 
Convert.ToInt32(..., 16);
 
i tried with that
it doens give 0x
prefixe
 
No, it doesn't.
Do you know how to add something to a string?
 
i know
 
6:58 PM
So then the question is what?
 
let me try the one you typed before
 
"0x" + Convert.ToString(x, 16);
 
0
Q: Why does this no longer render the "test tri"?

WardySo I got this code about rendering a shaded tri using sharpDX ... var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniTri.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None); var vertexShader = new VertexShader(device, vertexShaderByteCode); var pixelShaderByteCode = ShaderByteco...

anyone got any ideas on this ?
 
@LasseV.Karlsen or simply x.ToString("X");
 
which will work if the result is 2-digits, but not if it's one, but depends on what he wants.
Does he want 0x09 or 0x9
(for 9 that is)
or, yeah, I see what you mean now, yeah, of course
Convert was for the parse bit
Never mind me. (goes back to drinking more beer)
 
7:01 PM
 string str1 = "6c", str2 = "82";
                            var hex1 = "0x" + Convert.ToString(int.Parse(str1), 16);
                            var hex2 = "0x" + Convert.ToString(int.Parse(str2), 16);
                            if (data[start + 1] == hex1 && data[start + 2] == hex1)
                            { }
i tried like this
 
er wait
youre mixing strings and data man
 
lol
Convert.ToInt32 ?
 
instead of string right?
 
7:02 PM
your data is an array of bytes. it will never be equal to any string
 
if you already have the right hex values in strings, why are you even converting or parsing?
 
i dont have them
 
var hex1 = "0x" + str1;
var hex2 = "0x" + str2;
 
it was an example
 
so it was an example of what you don't have?
Then what was the point?
 
7:03 PM
kind of
but like this they are string too
 
they will not be eual
 
string str1 = "6c", str2 = "82";
                            var hex1 = "0x" + str1;
                            var hex2 = "0x" + str2;
                            if (data[start + 1] == hex1 && data[start + 2] == hex1)
                            { }
 
"1" != 1
 
i know
 
hex1 is a string
hex2 is a string
 
7:04 PM
but i really need to data[start + 1] == 0x6c
 
I feel like I still don't know what the actual question is.
 
i think the answer to the original question is you mixed up the numbers and their hex values =]
you had a c6 when you wanted a 6c
 
i need that a specific element from a byte array to be checked if it is equal with a hex number
no
 
if (a[x] == 0x6c) { ... }
 
7:05 PM
yes but 0x6c
in my case is in a string without prefixe
 
well
one of:
 
and i need to get into an integer with prefixe
 
crazy storm outside. brb.
 
if (a[x] == Convert.ToInt32("6c", 16)) { ... }
if (a[x].ToString("x2") == "6c") { ... }
 
let me try
it worked thanks
 
7:09 PM
Just wondering - why did you lie about what code you'd written? If you'd just said you were comparing strings to bytes, this would have been over an hour ago and wasted a lot less of people's time
 
string str1 = "6c", str2 = "82";
                            if (data[start + 1].ToString("x2") == str1 && data[start + 2].ToString("x2") == str2)
                            { }
@TomW im sorry i cant explain very good in english
 
Why are you writing the code like that anyway?
Wouldn't it be much better just like this?
if (data[start + 1] == 0x6c && data[start + 2] == 0x82) { }
 
it is
but i dont have those values
only i get the stirng like : stirng str = "6c"
and string str1 = "82"l
 
user1804599
Oops, wrong room. :v
 
user1804599
7:27 PM
@LasseV.Karlsen the actual question is probably still how to mix up value and representation.
 
7:47 PM
sigh I wonder why the ability to search the internet is not taught at school these days.
 
user1804599
Because teachers lack it.
 
Might be it.
Still depressing though.
 
user1804599
And it’s politically incorrect; thou shalt read books.
 
These days, books == google (or your favorite search engine)
 
user1804599
Like nuclear power, computers are obscure and therefore evil.
 
user1804599
7:49 PM
You have to read books instead.
 
user1804599
Reminds me of some moron in high school.
 
user1804599
She head to look up on the internet what <insert obscure chemical jargon here> meant.
 
user1804599
So she went to google.com and searched for “dictionary.” :facepalm:
 
10:57 PM
HelloWorld();
 
user2985029
11:48 PM
async
 

« first day (1379 days earlier)      last day (3569 days later) »