C # interview 3

Source: Internet
Author: User

1,Use an example to illustrate the benefits of generics.

 
Generic generics can store any reference or value type, avoiding explicit forced conversion.
 
List <int> List = new list <int> ();
 
List. Add (1, 100 );
 
List. Add ("A string"); // an error is returned.
 
When using a value type generic set, it is more efficient to avoid packing and disassembling operations.
 
The generic function provides the type security check and does not need to be compiled.CodeTo check whether the data type is correct, because the correct data type will be forcibly used during compilation. Reduces the need for forced type conversion and the possibility of running errors
 
2,Describe your common design patterns and explain what business logic you are using? Why is this pattern used?
 
2. Simple factory Model
 
By using the factory class, the outside world can get rid of the embarrassing situation of directly creating specific product objects, and only need to be responsible for "consuming" objects. Without having to worry about how these objects are created and organized, they clearly define their respective responsibilities and rights, which is conducive to the optimization of the entire software architecture.
 
Singleton Mode
 
The Singleton mode provides a globally unique access portal, which is easy to avoid conflicts. Generally, Global Counter objects and log management objects are used in multi-threaded environments.

Observer Mode

The observer mode defines a one-to-many dependency between objects. When the State of an object changes, all objects dependent on it are notified and automatically updated. A target can have any number of observers dependent on it. Once the status of the target changes, all observers are notified as responses to this notification, each Observer synchronizes the status of the query target with that of the target.

 
 

3,There are two ordered integer arrays (sorted in ascending order). Please writeAlgorithmFind the same and different elements.

 
Int [] num1 = new int [] {, 9} int [] num2 = new int}
 
Int commonnumint = 0;
 
Int diffentnumint = 0;
 
For (INT I = 0; I <num1.length; I ++)
 
{
 
For (Int J = 0; j <num2.length; j ++)
 
{
 
If (num1 [I] = num2 [J])
 
{
Commonnumint ++;
 
Break;
 
}
 
Else
 
{
 
If (j = num2.length-1)
 
{
 
Diffentnumint ++;
}
 
}
 
}
 
}
 
4The magazine business has two tables: the magazine information table and the journal table. Please briefly design the table structure and writeSQLFind the latest journals for all magazines.
 
Magazine info tableTbl_magazineinfo
 
Magazine No.: magazineid nvarchar (5) not null
 
Magazine name: magazinename nvarchar (20) not null
 
Author: magazineauthor nvarchar (20) not null
 
Publication date: magazinetime nvarchar (20) not null
 
Press name: magazinepubliname nvarchar (50) not null
 
 
Journal tableTbl_periodical
 
Journal No.: periodicalid nvarchar (5) not null
 
Magazine No.: magazineid nvarchar (5) not null
 
Journal name: periodicalname nvarchar (20) not null
 
Journal Time: periodicaltime nvarchar (20) not null
 
 
 
Select max (periodicaltime) from tbl_periodical where magazineid in (select magazineid from tbl_magazineinfo)
 
5News usually has multiple tags (keywords). Please design the table structure to describe the relationship between them. It is required that you can easily find the tags of a news and find all the news of a specified tag.
 
NewsTbl_newinfo
 
News ID: newid int not null
News name: newname nvarchar (20) not null
 
 
 
Tag InformationTbl_markinfo
 
Tag ID: markid int not null
 
Tag Name: markname nvarchar (20) not null
 
 
 
Intermediate tableTbl_nandm
 
ID: ID
 
News ID: newid int not null
 
Tag ID: markid int not null
 
Obtain multiple tags by specifying the news name
 
Select markname from tbl_markinfo where markid in (select markid from tbl_nandm where newid = (select newid from tbl_newinfo where newname = '2017 Spring Festival Gala '))
 
Obtain multiple news by tag
Select newname from tbl_newinfo where newid in (select newid from tbl_nandm where markid = (select markid from tbl_markinfo where markname = '文 '))

6Please design a mobile phone Address Book database that requires good compatibility (supports most models on the market) and good scalability.

(1) Mobile Phone type table (Tb_phonetype)

Typeid primary key ID (auto-incrementing ID)

Typename
Type name

Typedetail
Type description

(2) Address Book (Tb_commbook)

Id Primary Key (auto-incrementing ID)

Phonetype mobile phone type number (model)

Friendname
Friend name

Tel

Mobile phone

Adddate addition time

(3) Relational classification table (Tb_class)

Id Primary Key (auto-incrementing ID)

Classname category name

7Assume that an old system has performance problems, no source code, no database design documents, and C # + SQL2000Developed. How can you quickly locate the problem.

1. Use black box and stress tests to determine the performance problem (code problem, sqlserver problem)

2. Use reflectorProgramDecompile and check the code

3. Use sqlserver event probe to collect tracking information and check SQL statement performance and database deadlock.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.