Two types of Paths:
- Absolute - starts with a leading slash
- Relative - does not start with slash. Location depends on where you are using them
default.asp is: /pages/default.asp - if called from /pages/linktool.asp
Two special directory names:
. means current directory
.. means parent directory
../default.asp is /pages/default.asp if called from /pages/tools/linktools.asp
../../default.asp is /pages/default.asp if called from /pages/admin/tools/linktools.asp
~ tilde means root of the application
------------------------------------------------------------------
Nullable value types
private int? _copid;
protected double? d = 5;
The variable can be assigned "null". Normally primitives like "int" and "double" can't be null.
------------------------------------------------------------------
Null coalescing operator
x = y ?? z
x is assigned y's value. If y is null, then it's assigned z's value.
------------------------------------------------------------------
TryParse Method
Syntax: public static bool TryParse(string s, out int result)
if ( int.TryParse( itemId, out parsedItemId ) && parsedItemId > 0 )
Meaning: Parse itemId, assign it to parsedItemID as int. If parsedItemID is int and greater than 0 then...
------------------------------------------------------------------
(if) ? then : else
var objectInstance = condition ? foo : bar;
userType = user.Type == 0 ? "Admin"
: user.Type == 1 ? "User"
: user.Type == 2 ? "Employee"
: "The default you didn't specify";
------------------------------------------------------------------
Web.Config - Handling errors
Default value = RemoteOnly - which shows a pretty error page to remote users.
<system.web>
<customErrors mode="On">
</system.web>
Error message:
Error. An error occurred while processing your request.
Error view - just a razor view where you can modify it to include other information.
Views > Shared > Error.cshtml
No comments:
Post a Comment