473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Basic questions

Someone said that: [STAThread]/[MTAThread] in Main() only effect when
dealing with COM interop in console type application." Is this correct?

What if calling a regular DLL coded in C, instead of a COM object, is this
attribute still necessary?

Under what conditions should "[MTAThread]" be used instead of "[STAThread]"?
When to use "[STAThread]" then?

In a C#'s .cs file, a class is derived as ((1), (2) and (3) are added for
explanation):

public (1) class BaseForm : (2) Form
{
(3) string myString = " Hello, world!";

public BaseForm(){
...
}
...
}

What's the default modifier above before "Form" at place (2)and (3)?
Why "public" is used at (1)? If missing what's the default modifier at (1)?
Thanks in advance!

Nov 15 '05 #1
1 989

"p988" <p9**@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Someone said that: [STAThread]/[MTAThread] in Main() only effect when
dealing with COM interop in console type application." Is this correct?
Yes. Further, it's only "locked" after the first call to unmanaged code. You
can set the ApartmentState property of the current thread to change it.
What if calling a regular DLL coded in C, instead of a COM object, is this
attribute still necessary?
No.
Under what conditions should "[MTAThread]" be used instead of "[STAThread]"? When to use "[STAThread]" then?
Depends on what type of COM server you're talking to, or writing. In general
MTA should be used, but there's no "hard" rule.
public (1) class BaseForm : (2) Form
{
(3) string myString = " Hello, world!";

public BaseForm(){
...
}
...
}

What's the default modifier above before "Form" at place (2)and (3)?
Why "public" is used at (1)? If missing what's the default modifier at

(1)?

Inheritance is always public in C# (unlike C++ where it can be private), so
(2) implies public. (3) is private by default. (1) is internal (to the
containing assembly) by default, IIRC.

--
____________________
Klaus H. Probst, MVP
http://www.vbbox.com/
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
8
by: Orange Free | last post by:
I want to create a program that will ask a user a series of questions and then generate a Microsoft Word document whose content is dictated by the answers. I am not a professional programmer, and...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
2
by: Steven O. | last post by:
First, this may not be the correct newsgroup. I have some relatively basic questions on SQL. I tried to find a newsgroup that was specifically just about SQL, and was surprised to find that all...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
3
by: Jim H | last post by:
If there is a site someone can point me to that answers such basic questions, rather than taking up support's time posting answers, please let me know. I've developed C# .NET, unmanaged C++, and...
2
by: Fay Yocum | last post by:
BEWARE beginner questions!! I have some experience in Access but never as much as I want or need. I have decided to get in on VB.Net. I would only rate myself in Access as a...
0
by: software2006 | last post by:
ASP And Visual Basic Interview questions and answers I have listed over 100 ASP and Visual Basic interview questions and answers in my website...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
2
by: LayneMitch via WebmasterKB.com | last post by:
Hello. This is a basic quiz. Only about 3 questions. I'm having issue with the answer key which stays on a certain value regardless of acknowledging that you have the correct answer for the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.