discards - , . , , , , , , , :
public static void Main(string[] args)
{
ModifyRecords();
}
public static Int32 ModifyRecords()
{
Int32 affectedRecords = 0;
for (Int32 i = 0; i < s_Records.Count; ++i)
{
Record r = s_Records[i];
if (String.IsNullOrWhiteSpace(r.Name))
{
r.Name = "Default Name";
++affectedRecords;
}
}
return affectedRecords;
}
, ... , ( ), , .
, , , . String Boolean, , - . , String Boolean (a regular expression... if , ), , , , , .
, , :
public static void Main()
{
var (_, _, _, pop1, _, pop2) = QueryCityDataForYears("New York City", 1960, 2010);
Console.WriteLine($"Population change, 1960 to 2010: {pop2 - pop1:N0}");
}
private static (string, double, int, int, int, int) QueryCityDataForYears(string name, int year1, int year2)
{
int population1 = 0, population2 = 0;
double area = 0;
if (name == "New York City")
{
area = 468.48;
if (year1 == 1960) {
population1 = 7781984;
}
if (year2 == 2010) {
population2 = 8175133;
}
return (name, area, year1, population1, year2, population2);
}
return ("", 0, 0, 0, 0, 0);
}
, , , , discards , C#, .
Matlab discards , , , (, , ). ( ):
fileparts:
helpFile = which('help');
[helpPath,name,ext] = fileparts('C:\Path\data.txt');
: helpPath, name ext. . , . , .
, (~):
[~,name,ext] = fileparts(helpFile);
, Matlab , , , .