Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm looking how to use correctly the Lenght method, I'm not c# developer, first time looking into code so basically try to get throw using documentation, so I build an validation code that uses string.IsNullOrEmpty to check if the fieldName.name is either empty or null, this is working
var namepropName = PathFinder<InfoField>.Get(i => i.fieldName.name);
RegValidation(namepropName, (x, y) => {
ValueRequired(, () => string.IsNullOrEmpty(x.fieldName.name));
});
Now I trying to check if the fieldName.name length is bigger than 20 characters.
The below code is throwing errors, how can I use string.Length is bigger than 20 correctly?
ValueRequired(, () => string.Length > 20 (x.fieldName.name));
ValueRequired(, () => x.fieldName.name.Length > 20);
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I tried making a program where every few seconds a random letter dropped. I noticed that the "correct" one dropped to rarely. I made a int correctLetterDrop = Random.Range(0,100) and wanted to artificially increase the chance. The rest of the code handles everything, i just need to assign the correct sprite to check against.
This gives me an error at the .correctSprite; saying "else cannot start a statement". I expect it to just check if the Random.Range returned 7 or less (for a 7% chance) and if it did to set the correct one, and otherwise just set a random one.
if(correctLetterDrop <= 7){
Clone.GetComponent<SpriteRenderer>().sprite = correctLetterScript.correctSprite;
else{
Clone.GetComponent<SpriteRenderer>().sprite = Letters[Letter];
}
}
Check for the first if condition closure }:
if(correctLetterDrop <= 7) {
Clone.GetComponent<SpriteRenderer>().sprite = correctLetterScript.correctSprite;
}else{
Clone.GetComponent<SpriteRenderer>().sprite = Letters[Letter];
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to read the first line in a file, but I keep getting this error every time I do sr.ReadLine(1); and I can not find an answer to this error.
My code:
using (StreamReader sr = new StreamReader(DataStore))
{
string Conent;
Conent = sr.ReadLine(1);
};
As per the docs, the method should be called with no parameters i.e.
sr.ReadLine()
Since I just had and solve a problem like you're facing. Just code
sr.Readline()
Also you might wanna add some Error minimization if you're going to read it line by line in a while/loop like this.
while ((content = sr.Readline()) !=n null && (line != ""))
{
your code
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Considering this C#.NET code:
DateTime.Now.ToString("yyyyMMddHHmmssfff")
, is there any equivalent in PHP?
For the moment, I use the following:
$date = new DateTime();
$timestamp = $date->getTimestamp();
$formatted_timestamp = gmdate("YmdHms", $timestamp) . round(microtime(true) * 1000);
However, it doesn't output the same results (from the seconds).
Since you're already using a DateTime object, you could simply format it:
$date = new DateTime();
return $date->format('YmdHisv');
the 'v' is what you're looking for (milliseconds).
Caution: this requires PHP 7.1, if you instantiate DateTime() with no arg, in order to obtain some non-0 milli (or micro) seconds.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a list of cleaners (linq class) I am trying to remove 'cleaners if they are unconfirmed. Here is my code.
List<ConfirmCleaner> Unconfirmed = context.ConfirmCleaners.Where(d => d.confirmed == false).ToList();
List<Cleaner> Cleaners = context.Cleaners.ToList();
List<Cleaner> TempCleaners = new List<Cleaner>();
foreach (var c in Unconfirmed)
{
foreach(var r in Cleaners){
if(c.cleanerId == r.id){
TempCleaners.Add(r);
}
}
}
List<Cleaner> result = Cleaners().Except(TempCleaners()).ToList();
return result;
Why am I getting an error :
'Cleaners' is a 'variable' but is used like a 'method'
The problem is this line:
List<Cleaner> result = Cleaners().Except(TempCleaners()).ToList();
You need to change it to:
List<Cleaner> result = Cleaners.Except(TempCleaners).ToList();
Hope that the error message is clear enough to identify the issue, anyway you have declared Cleaners as a List of Cleaner, and When you were using that variable in the final query you are using the same like Cleaners(). When you use like this, the compiler expects a method, and that is what the compiler specified in the error message as well. So the code should be :
return Cleaners.Except(TempCleaners()).ToList();
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
testExceptions is Dictionary.
var testConfigurations = cells.SelectMany(x => x.TestConfigurations).Where(
y => y.ID == testId &&
!testExceptions[index].ContainsKey(y.Cell) &&
!testExceptions[index][y.Cell].Contains(y.ID)
).ToList();
!testExceptions[index][y.Cell].Contains(y.ID) is giving me an exception when testExceptions doesn't contain key y.Cell. But since I was checking ContainsKey I expected it will not evaluate last condition. Is there any way to avoid exception without using long if/else statements?
You're checking if it doesn't contain the key. You need to check if it does contain the key:
testExceptions[index].ContainsKey(y.Cell) && ... use the key ...