|
If you are going to be paid by the line, then you should continue this with lower case, punctuation and the other oddities available in the local character set...
It would have been far to easy too write
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
}
So we won't mention it.
Or at least I won't.
Oh bum.
modified on Sunday, April 19, 2009 5:44 AM
|
|
|
|
|
Except I just realized that to fit with his "coding style" I should have suggested
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
}
I feel better now.
Unclean, but better.
|
|
|
|
|
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
}
I must agree. This is a much better option. But I will keep the idea of checking each value, and ALSO use this pattern. So:
case 'G':
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
case 'H':
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
As this is the original pattern from 0 to 8 (9 is NOT a number, LOL).
|
|
|
|
|
|
Why not check if the char equal 10? And since your getting payed by line go on till you reach the max value of an int64?
Cheers
|
|
|
|
|
I'm doing A LOT of such stuff nowadays. In assembly. (AT&T syntax)
# READ (char* bufer, int bufer_len)
# Reads a number from an ascii buffer and returns an actual number in eax
#
# PARAMETERS
# 1. Address to the buffer
# 2. The string's length
#
# Used registers:
# esi - contains all read characters
# ecx - index inside the buffer
# ebx - used in a conversion process char -> int
# edx - address to the buffer
# eax - the result
.globl read
.type read, @function
read:
.equ DIGIT_0,'0'
.equ DIGIT_9,'9'
.equ CASE_A,'A'
.equ CASE_F,'F'
.equ CASE_a,'a'
.equ CASE_f,'f'
.equ ONE_DIGIT_MASK, 0x0000000F
mov 8(%esp), %esi # save number of read chars
mov $0, %ecx
mov $0, %eax # there was the zero at the beginnig of the Universe
cmp %ecx, %esi # empty string case
je read_done
read_loop:
mov $0, %ebx
mov 4(%esp), %edx
#mov (%edx), %edx
mov (%edx, %ecx, 1), %bl # take the next char
cmp $DIGIT_9, %bl
jle read_0to9
read_AtoF:
cmp $CASE_a, %bl
jge read_AtoF_lowercase
sub $CASE_A, %bl # substitute'A'
jmp read_AtoF_continue
read_AtoF_lowercase:
sub $CASE_a, %bl # substitute 'A'
read_AtoF_continue:
add $10, %bl # add 10 to get the correct value
jmp read_char_done
read_0to9:
cmp $DIGIT_0, %bl
jl read_done
sub $DIGIT_0, %bl # substitute '0'
jmp read_char_done
read_char_done:
# (bl is a lower part of ebx)
add %ebx, %eax # ebx is a read-to-eat int
inc %ecx # increment the index
cmp %ecx, %esi # check if we're done
je read_done
shl $4, %eax # shift the number by one hex digit capacity.
jmp read_loop
read_done:
ret
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
What's with all the 'break' statements after 8? He didn't need them before? Or does he hope that Convert.ToInt32 does some voodoo that never returns to the switch block?
|
|
|
|
|
Brilliant! Aren't we glad English has only 26 letters? I'd like to see the Chinese version of the code (thousands of letters).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
User Class part :
Public Property SetChallengedCardList() As Integer
Set(ByVal value As Integer)
_challengedCardList.Add(value)
End Set
Get
Return 0
End Get
End Property
Public Property GetChallengedCardList() As ArrayList
Set(ByVal value As ArrayList)
_challengedCardList = Nothing
End Set
Get
Return _challengedCardList
End Get
End Property
and latter usage:
Dim u As New User()
u.SetChallengedCardList = 25
u.SetChallengedCardList = 27
u.SetChallengedCardList = 31
sstanko78
modified on Thursday, April 16, 2009 6:07 AM
|
|
|
|
|
|
Proper solution would be:
Private _challengedCardList As ArrayList
Public Sub AddItemToChallengedCardList(ByVal value As Integer)
_challengedCardList.Add(value)
End Sub
Public ReadOnly Property GetChallengedCardList() As ArrayList
Get
Return _challengedCardList
End Get
End Property
It was 21.00h in the office, so ....
sstanko78
|
|
|
|
|
sstanko78 wrote:
Public ReadOnly Property GetChallengedCardList() As ArrayList
Get
Return _challengedCardList
End Get
End Property
Isn't that mutable? You shouldn't return the whole array as it could then be changed from /outside/. Then puppy's cry.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hey,
I'm used to returning the whole array, and I know that it then can be muted, but dno how to prevent this. Could you give an example of how it should be done?
Cheers
BN
|
|
|
|
|
AFAIK you have to clone the array.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
dan neely wrote: AFAIK you have to clone the array.
No, just wrap it:
System.Collections.Generic.List<string> mutable = new List<string>();
System.Collections.ObjectModel.ReadOnlyCollection<string> immutable = mutable.AsReadOnly();
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Does that work with normal arrays as well as List<>'s?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Do I look like I know!
I was going to flippently say for usre, but I am unable to find it.
In Java the base Collection supports immutable references, too late of evening for me to look, and so that goes through all the Map and Set classes. It seems a sensible approach; just not for M$.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
OK. Until recently I've been doing 1.1 framework stuff , and was wondering if this was an new feature or something I'd managed to not discover in several years of using the language.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Thnx dude, didn't know that
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
Not a coding horror as such, but I fondly remember being given a 250 page software specification which ended
"Then a miracle occurs"
Cheers Phil!
|
|
|
|
|
|
Bed Time Story:
Once up on a time, there was
OriginalGriff wrote: 250 page software specification
who lived on paper happily, then it got transferred to code and ...
OriginalGriff wrote: "Then a miracle occurs"
The End!
Good Night
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
No, that's not a horror. That is someone giving stating what really needs to happen in order for the project to work.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
If the worst horror you could find in my company is ranked 10 and a moderate horror is ranked 1, I think I could rank this with 5:
Dim key As String
key= "N"
key= "linatipedi=" + "'" + key+ "'"
Dim rR As DataRow() = t.Select(key)
If rR.Length() = 0 Then
i = 0
Else
Try
For Each r In rR
i += 1
Next r
Catch
If i = 0 Then
Return True
Else
Return False
End If
End Try
End If
If i = 0 Then
Return True
Else
Return False
End If
|
|
|
|
|
adgonz wrote: I think I could rank this with 5
That is because VB's scale starts at 5
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|