15,917,456 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by andres_fprado (Top 6 by date)
andres_fprado
7-May-19 22:55pm
View
This does not comply with the original question. The submitted program is expected to work with numbers up to 1000 digits long. Numbers that long can not be represented by any of the built-in numeric types (not even by decimal).
andres_fprado
9-Apr-16 1:18am
View
Try with:
<td>@(item.purpose == null) ? "" : (item.purpose.protype_purpose_name ?? "")</td>
andres_fprado
9-Apr-16 1:10am
View
Good luck! This is a little understood (and quite useful) operator in C#. I've used it in similar situations as the one you described. Hope it helps.
andres_fprado
9-Apr-16 1:05am
View
You could do that with:
<td>@item.prototypecategory.prototype_category_name ?? "no" </td>
andres_fprado
9-Apr-16 0:59am
View
No, you don't need the second <td></td> at all. You would just write:
<td>@item.prototypecategory.prototype_category_name ?? "" </td>
In Razor, the first <td> will always be emitted (written to the output). Then, the @ means to evaluate the C# expression and emit the result (which will be either the value of your variable, if not null, or an empty string otherwise). Finally, the closing </td> will always be emitted.
So, if the variable's value was "test", you would get <td>test</td>, and if it was null, you would simply get <td></td>.
andres_fprado
9-Apr-16 0:54am
View
In Razor, what you enter after the "@" must be a valid C# expression. In this case, I'm proposing you use the "??" operator. This is a binary operator, which translates essentially as:
x = a ?? b
is equivalent to
if(a != null)
x = a;
else
x = b;
Therefore, you must have a valid C# expression after the ?? operator. For example, if you want the <td></td> to empty, you would put ?? "" after the expression you are evaluating (which means, 'if the expression is null, replace with an empty string).
Show More