StreamWriter viet = null;
try
{
SaveFileDialog sDlg = new SaveFileDialog( );
sDlg.Filter = "Text File(*.txt) | *.txt | All Files(*.*) | *.*";
if (sDlg.ShowDialog( ) = = DialogResult.OK)
{
viet = new StreamWriter(sDlg.FileName);
viet.Write(txtNoidung.Text);
}
} catch (Exception ex)
{
MessageBox.Show(ex.ToString( )) ;
} finally
{
viet.Close( );
}
What will be the fragment of above code?
A -
Write contain text txtNoidung to file Data.txt
B -
The code will generate an error
C -
Write contain text in txtNoidung to file chose in SaveFileDialog sDlg
D -
All way save text in txtNoidung to file Data.txt
2-
String indexers treat strings as:
A -
1 to string Lenght
B -
arrays of chareacters
C -
binary code
D -
a character
3-
String mystring; Creates a(n) ____.
A -
Object
B -
property
C -
Constructor
D -
Class
4-
StringBuilder buffer = new StringBuilder("Hello, how are you?");
buffer = buffer + buffer.Append("Thang");
What will be the fragment of above code assign to buffer variable?
A -
The code will generate an error
B -
Hello, how are you? Thang
C -
Hello, how are you?Thang
D -
None of the others answers
5-
StringBuilder buffer = new StringBuilder("Hello, how are you?");
buffer.Lenght = 6;
buffer.Append("To day!");
What will be the fragment of above code assign to buffer variable?
A -
Hello, how are you? Today!
B -
The code will generate an error
C -
Hello, Today!
D -
None of the other answers
6-
StringBuilder buffer = new StringBuilder("Hello, how are you?");
buffer.Insert(5, 123);
What will be the fragment of above code assign to buffer variable?
A -
Hello123, how are you?
B -
The code will generate an error
C -
Hello123o, how are you?
D -
None of the other answers
7-
StringBuilder buffer = new StringBuilder("Hello, how are you?");
buffer = buffer + buffer.Replace("Hello", "Hello Thang");
What will be the fragment of above code assign to buffer variable?
A -
Hello Thang
B -
None ofther other answers
C -
The code will generate an error
D -
Hello Thang, how are you?
8-
Suppose the first two lines of the file DATA.TXT contain the strings "Clint" and
"1930". What is Displayed by the following lines of code?
try
{
OpenFileDialog dlg = new OpenFileDialog( );
dlg.Filter = "Text File(*.txt) | *.txt | All Files(*.*) | *.*};
dlg.FilterIndex = 1;
dlg.Multiselect = false;
if (dlg.ShowDialog( ) = =DialogResult.OK)
{
StreamReader doc = new StreamReader (dlg.FileName);
string nd1 = doc.ReadLine( );
int nd2 = Convert.ToInt32 ( doc.ReadLine( ));
txtNoidung.Text = "In 2008, " + nd1 + " will be " + (2008 – nd2);
doc.Close ( );
}
} catch (Exeption ex)
{
MessageBox.Show(ex.Tostring( ));
}
A -
j In 2008, "Clint" will be 78
B -
In 2008, "Clint" will be 78
C -
j Clint,1930
D -
j In 2008, Clint will be 2008-1930
9-
The DoWork method increments a the argument:
static void DoWork(out int param)
{
param = 42;
}
stattic void Main( )
{
int arg;
DoWork(out arg);
Console.WriteLien(arg);
}
The result on the screen is:
A -
example does not compile by error syntax
B -
Write a random value
C -
writes 42
D -
example does not compile by error because arg is initialized