|
So cell isn't stored in the bit +9....? Index 3 is an empty string in his example.
Nevermind - I see what you're saying. I'd missed the , in the date.
I'm not a stalker, I just know things. Oh by the way, you're out of milk. Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Tuesday, March 29, 2011 9:40 AM
|
|
|
|
|
You could use a regular expression but then you may end up with not one problem but two
using System.Text.RegularExpressions;
...
string txt = "+CMGR: \"REC READ\",\"+923365483536\",,\"10/09/15,08:16:11+20";
Match m = Regex.Match(txt, @"[0-9]{2}/[0-9]{2}/[0-9]{2},[0-9]{2}:[0-9]{2}:[0-9]{2}");
if(m.Success)
{
String date = m.Value.Replace(",", " ");
DateTime dt = DateTime.Parse(date);
}
The snippet above should work but you may want to refine the expression. I just hacked that one up quickly
"You get that on the big jobs."
|
|
|
|
|
May I humbly suggest Rive[^]?
|
|
|
|
|
Try to use regular expression,MAN.
Hope this helps.
Hi, i am from china.Like to make friends with you from all of the world.
|
|
|
|
|
It's very easy
First store the entire string in a string variable
and then use the split method and assign it to a character array
split(",,")
and from that array fetch the appropriate value like
string s="+CMGR: "REC READ","+923365483536",,"10/09/15,08:16:11+20";
char[] temp=s.split(",,");
now your temp[1] consists both time and date.
if you want separate both use the same technique.
|
|
|
|
|
Hi,
I get a program c# when googling that validates the IBAN :
static bool isIban (string code_iban)
{
code_iban = code_iban.ToUpper () ;
StringBuilder sb = new StringBuilder ();
foreach ( char car in code_iban)
{
if (char.IsDigit (car) || char.IsLetter (car))
sb.Append (car);
}
code_iban = sb.ToString ();
if (code_iban.Length < 15 || code_iban.Length > 34)
return false;
string iban = code_iban.Substring(4, code_iban.Length - 4) + code_iban.Substring(0, 4);
StringBuilder sb2 = new StringBuilder ();
foreach (char c in iban)
{
int entier;
if (char.IsLetter(c))
entier = Convert.ToChar (c) - Convert.ToChar ("A") + 10;
else
entier = Convert.ToChar (c) - Convert.ToChar ("0");
sb2.Append (entier);
}
string checkSumString = sb2.ToString();
int checksum = int.Parse(checkSumString.Substring(0, 1));
int i = 1;
while (i < checkSumString.Length)
{
int v = int.Parse(checkSumString.Substring(i, 1));
checksum *= 10;
checksum += v;
checksum = checksum % 97;
System.Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
}
if (checksum == 1)
return true;
else
return false;
}
}
I understand all only the functionality of System.Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
ty
|
|
|
|
|
Well, Math.Max is retrieving the maximum of i or i-1. Interlocked.Increment is used to increment i and store it all as an atomic action.
|
|
|
|
|
Hi,
If u can give me the // algorithme of this.I can do this like this simply
Math.Max( ref i , i-1)
i ++;
why using of Interlocked.Increment???????
ty
|
|
|
|
|
You shouldn't. In this case, it's absolutely no use whatsoever - frankly, it looks like somebody is trying to be too clever for their own good. Interlocked increment only makes sense in multi-threaded scenarios where there is a possibility that somebody else may increment a shared variable. As i is local, it's pointless. This code looks like obfuscation through stupidity.
|
|
|
|
|
Pete O'Hanlon wrote: obfuscation through stupidity
5
|
|
|
|
|
This line:
System.Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
seems utterly stupid to me. Comparing a number which is increased to what it was before and taking the maximum will always return the increased number. Even so, nothing is done with the return value. And why is this increase done using the interlocked class? Doesn't look terribly multi-threaded to me and if it is then you need additional locking.
i++ is probably what you want, and I would expect the loop initialisation to set i = 0 , rather than i = 1 on casual inspection.
Regards,
Rob Philpott.
|
|
|
|
|
it doesn't make sense at all; i is a local variable, no other thread can touch it, so the whole statement boils down to i++ and the while loop should have been a for loop.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You have already asked about this here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yes, however this time there was a whole new sentence, and a big code snip, so we could provide more relevant comments.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
And he is using C# not JavaScript
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
He is flexible for now, in the end he'll really want JavaScript code doing the same. Just you wait.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Using a a Binder class for connecting all Event and Handlers of classes can make those classes fully decoupled. Is it the standard way to implement a project ?
|
|
|
|
|
Is this a WinForms application? ASP.NET? WPF? Silverlight?
Whether binding is used as standard depends on which type of application it is.
|
|
|
|
|
Could we consider it a design pattern for general ?
I think it's useful for building desktop application.
|
|
|
|
|
You can use it in pretty much any type of application, but how easy it is depends on the underlying infrastructure. WPF and Silverlight are built with binding in mind, so pretty much everything can be databound and the separation is a well known pattern called MVVM. WinForms provides less support for binding. If you're looking for a decoupled event subsystem, I wrote an EventPool[^] here that might be of interest.
|
|
|
|
|
|
hi,
i've got some warnings which i couldnt resolve... Could somebody pls help me with it?
The list of warnings are:
Warning 1 Object reference not set to an instance of an object. 0 0
Warning 2 The referenced component 'DockingToolbar' could not be found.
Warning 3 The referenced component 'ImageLib.Imaging' could not be found.
Warning 4 The referenced component 'ImageLib.Math' could not be found.
Warning 5 The referenced component 'SourceGrid2' could not be found.
Warning 6 The referenced component 'SourceLibrary' could not be found.
Warning 7 The referenced component 'WeifenLuo.WinFormsUI' could not be found.
|
|
|
|
|
for first one that is "Warning 1 Object reference not set to an instance of an object.0 0"
you may have just declaring object.....
but not create instance.......
for example.......
suppose one class Triangle
then,
1.Declare object of Triangle class
private triangleObj;
2. You may don't have do the following step before using it so just do it
triangleObj = new Triangle();
Thanks.........
|
|
|
|
|
When you see errors warning you that component X could not be referenced, this normally means that the application is referencing a DLL (or DLLs) that no longer exist at the path it was picked up from. To identify whether or not this is the problem, take a look at the references for your application - if there's a little yellow warning triangle on some of the references, then these are the culprits, and they will need to be dropped and readded to your project.
|
|
|
|
|
The first thing to do is to look at each one in turn: and treat each warning as if it was an error - it probably is, and will cause other problems later when you run your code.
Compile your app. Look at the error pane. Double click on the first warning - VS will take you to the line involved.
The first one is obvious: you have declared a variable, but VS thinks it can see a path by which it can be used without being set first. Normally, this is because either you haven't set it at all, or there is a logic condition which sets it one of two ways, but VS thinks it might not get to one of the two. For example:
private int GetTotal(int[] values)
{
int total;
foreach(int value in count)
{
total = Sum(value);
}
return total;
} You know that values will never be empty - but VS doesn't.
The other errors are harder, without knowing more.
Look at each line, and try to see what VS is talking about!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|