|
TupleWare to the rescue.
5!
|
|
|
|
|
I may start organizing some TupleWare meetings at home... Will give feedback
|
|
|
|
|
Yup, Good Answer.
Take a 5
|
|
|
|
|
Thanks to both of you
I discovered this object a few weeks ago and found it quite useful for situations where creating a custom class would have caused an unnecessary overhead.
|
|
|
|
|
IMHO using Tuple s is a bad practice, similarily to Func and Action delegates. Things should have name. I don't like LINQ extensions for that - I need to remember order of parameters in all these Func s.
Greetings - Jacek
|
|
|
|
|
If you're not using .NET 4, you might want to try Generics as an alternative;
class SomeValue<T>
{
public T FirstValue { get; set; }
}
class SomeValues<T, U>: SomeValue<T>
{
public U SecondValue { get; set; }
}
class TooMuchValues<T, U, V>: SomeValues<T, U>
{
public V ThirdValue { get; set; }
}
static void Main(string[] args)
{
TooMuchValues<String, Int32, String> record = new TooMuchValues<String, Int32, String> ()
{
FirstValue = "Hello",
SecondValue = 1,
ThirdValue = "World"
};
Console.WriteLine ("{0}{1}{2}", record.FirstValue, new String(' ', record.SecondValue), record.ThirdValue);
}
You could add them to a List and enumerate them. I wouldn't recommend it outside prototyping-code though, as it doesn't improve readability (read 'maintainability').
I are Troll
|
|
|
|
|
Hi,
Pattern: \d+(?:\.{0,1}\d+)?
I wrote the above pattern to validate the below data
100
100.
100.80
Its working fine with the above data. But it is accepting "100/80" and "100 80" also..
Please help to resolve this. Thanks in advance.
|
|
|
|
|
Use "^\d+(?:\.{0,1}\d+)?$ " Instead.
Because you haven't mentioned starting and ending of the string.
so for 100/80 there will be two match 100 and 80. So that it will be validated as a true.
Hope it solves.
|
|
|
|
|
It is not validating "100."
|
|
|
|
|
I hope you want regex is based on some sense.
Are you sure "100." is a valid decimal or It has any meaning ?
If you want to pass 100. any way then use "^\d+\.{0,1}(?:\d+)?$ ".
|
|
|
|
|
this might help
\d+[.]{0,1}\d*
|
|
|
|
|
Have you checked it by value 100/12 , That's the problem of OP.
In your case it will return 2 Matches, Just need to wrap Regex in ^Regex$ to solve the issue.
|
|
|
|
|
Below one solved the problem. Thanks alot Hiren and Ravi
"^\d+[.]{0,1}\d*$"
|
|
|
|
|
HaroldVish wrote: Thanks alot Hiren
You're welcome, You can always rate the answer which helped you, That encourages the person to give answer.
|
|
|
|
|
its validating "50-99"
But it shouldn't
|
|
|
|
|
You should have asked this in the regular expression forum. It needs more traffic.
|
|
|
|
|
Ok, I didn't notice Regular expression has separate forum
|
|
|
|
|
Nobody does. It's why I was trying to boost the traffic to it and not do the usual stamp down hard on the poster thing.
|
|
|
|
|
Hi,
I am trying to do a search in VSTO Word add-in 2007 from background thread or background worker. I'm getting an exception "External component has thrown an exception".
Range range = document.Content;
Find findSpell = range.Find;
findSpell.Text = "test";
It works when I invoke it directly from the same thread.
Is there any possibility to do this in background thread because this is lengthy operation?
PS
I'm trying to achieve similar functionality as spelling and grammar
|
|
|
|
|
How Can I Upload and Resize Image in PHP?
|
|
|
|
|
You could start by READING THE NAME OF THE FORUM!
Sorry about the shouting, but it's been one of those days - and it's only 09:15...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Come on, take it easy, it's friday. Hear me? TAKE IT EASY
Edit: Oh, come on, guys. I was just kidding... It's friday...
modified on Friday, December 17, 2010 11:54 AM
|
|
|
|
|
Hello All,
I found the need to use enumeration as indexer to simplify coding and just realized, I created bugs all over.
The situation is like this...
using System;
using System.Collections.ObjectModel;
namespace Demo
{
class Program
{
public enum AFormatType
{
None = 0,
ItemA = 1,
ItemB = 2,
ItemC = 3,
ItemD = 4,
}
public class AFormat
{
AFormatType _type;
public AFormat(AFormatType type) { _type = type; }
public AFormatType FormatType
{
get { return _type; }
}
}
public class AFormatCollection : Collection<AFormat>
{
public AFormat this[AFormatType type]
{
get
{
for (int i = 0; i < this.Count; i++)
{
AFormat format = base[i];
if (format.FormatType == type)
{
return format;
}
}
return null;
}
}
}
static void Main(string[] args)
{
AFormatCollection collFormats = new AFormatCollection();
collFormats.Add(new AFormat(AFormatType.ItemA));
collFormats.Add(new AFormat(AFormatType.ItemB));
collFormats.Add(new AFormat(AFormatType.ItemC));
collFormats.Add(new AFormat(AFormatType.ItemD));
AFormat testFormat = collFormats[0];
}
}
}
I was surprised to find that the testFormat is null . Is the C# enum nothing better than the C++? If the compiler considers this to be another this[int index] , why did this compile successfully?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
modified on Saturday, December 18, 2010 1:24 AM
|
|
|
|
|
0 is always legal when an enum is expected
From the C# language spec:
13.1.3 Implicit enumeration conversions
An implicit enumeration conversion permits the decimal-integer-literal 0 to be converted to any enum-type.
|
|
|
|
|
harold aptroot wrote: 0 is always legal when an enum is expected
I think that explains the issue, since the output of the ff. are the same: ItemC .
(NOTE: reversed the content)
static void Main(string[] args)
{
AFormatCollection collFormats = new AFormatCollection();
collFormats.Add(new AFormat(AFormatType.ItemD));
collFormats.Add(new AFormat(AFormatType.ItemC));
collFormats.Add(new AFormat(AFormatType.ItemA));
collFormats.Add(new AFormat(AFormatType.ItemB));
testFormat = collFormats[1];
if (testFormat != null)
{
Console.WriteLine(testFormat.FormatType.ToString());
}
testFormat = collFormats[AFormatType.ItemC];
if (testFormat != null)
{
Console.WriteLine(testFormat.FormatType.ToString());
}
}
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|