Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

string is an alias in C# for System.String.
So technically, there is no difference. It's like int vs. System.Int32.

As far as guidelines, it's generally recommended to use string any time you're referring to an object.

e.g.
***
string place = "world";
***
Likewise, I think it's generally recommended to use String if you need to refer specifically to the class.

e.g.
***
string greet = String.Format("Hello {0}!", place);
***
3 years ago
px - Pixels - point per scale corresponds to actual pixels on the screen.

i - Inches - based on the physical size of the screen.

mm - Millimeters - based on the physical size of the screen.

pt - Points - 1/72 of an inch based on the physical size of the screen.

dp - Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both dip and dp, though dp is more consistent with sp.

sp - scalable pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommended that you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

Take the example of two screens that are the same size but one has a screen density of 160 dpi (dots per inch, i.e. pixels per inch) and the other is 240 dpi.
***
Lower resolution screen Higher resolution, same size
Physical Width 1.5 inches 1.5 inches
Dots Per Inch (“dpi”) 160 240
Pixels (=width*dpi) 240 360
Density (factor of baseline 160) 1.0 1.5

Density-independent pixels 240 240
(“dip” or “dp” or “dps”)

Scale-independent pixels
(“sip” or “sp”) Depends on user font size settings same
***
3 years ago
PUT /user/12345 HTTP/1.1 <-- create the user providing the id 12345
Host: mydomain.com

GET /user/12345 HTTP/1.1 <-- return that user
Host: mydomain.com
Otherwise, use POST to initially create the object, and PUT to update the object:

POST /user HTTP/1.1 <--- create the user, server returns 12345
Host: mydomain.com

PUT /user/12345 HTTP/1.1 <--- update the user
Host: mydomain.com
3 years ago
An illustration of when to prefer the first method to the second one is when you need to avoid overriding a function's previous definitions.

With
***
if (condition){
function myfunction(){
// Some code
}
}
***
, this definition of myfunction will override any previous definition, since it will be done at parse-time.

While
***
if (condition){
var myfunction = function (){
// Some code
}
}
***
does the correct job of defining myfunction only when condition is met.
3 years ago
let is interesting, because it allows us to do something like this:
***
(() => {
var count = 0;

for (let i = 0; i < 2; ++i) {
for (let i = 0; i < 2; ++i) {
for (let i = 0; i < 2; ++i) {
console.log(count++);
}
}
}
})();
***
Which results in counting [0, 7].

Whereas
***
(() => {
var count = 0;

for (var i = 0; i < 2; ++i) {
for (var i = 0; i < 2; ++i) {
for (var i = 0; i < 2; ++i) {
console.log(count++);
}
}
}
})();
***
Only counts [0, 1].
3 years ago
URI => Uniform Resource Identifier Identifies a complete address of resource i-e location, name or both.

URL => Uniform Resource Locator Identifies location of the resource.

URN => Uniform Resource Name Identifies the name of the resource
3 years ago
***
import React, { PureComponent, Fragment } from 'react';
import ReactDOM from 'react-dom';

class Select extends PureComponent {
state = {
options: [
{
name: 'Select…',
value: null,
},
{
name: 'A',
value: 'a',
},
{
name: 'B',
value: 'b',
},
{
name: 'C',
value: 'c',
},
],
value: '?',
};

handleChange = (event) => {
this.setState({ value: event.target.value });
};

render() {
const { options, value } = this.state;

return (


Favorite letter: {value}



);
}
}

ReactDOM.render(