"You cannot use accessor modifiers on an interface or an explicit interface member implementation."
Means we can not put modifier on interface declaration of accessor, and also can not use modifier on the class implementation of the accessor (which is declared in interface).
"When you use an accessor to implement an interface, the accessor may not have an access modifier. However, if you implement the interface using one accessor, such as get, the other accessor can have an access modifier, as in the following example:"
It means if interface only declare one accessor, either get/set, then in the class implementation, for the interface declared accessor, either get/set, we can not use any modifier, but for the other accessor, which is not declared in interface, either set/get, we can add modifier.
I don't know, I can't answer your question without either reading the documentation,
or trying it in Visual Studio; you can do those things equally well yourself.
Anyway, if I don't know today it tells me it probably is not important, i.e. I tend to put
an access modifier and when it is not allowed the compiler will tell me. So you can
call me pragmatic, I want to know a lot but I don't feel a need to know it all,
ceetainly not when the tools are available and adequate to correct me in time.
I have read all the mail merge threads and articles I could find, and I'm a little frustrated at the moment... I really hope someone could help me here!
I found a very simple approach to merging, which I've implemented, and the code is show below:
//OBJECT OF MISSING "NULL VALUE"<br />Object oMissing = System.Reflection.Missing.Value;<br />
//OBJECTS OF FALSE AND TRUE<br />Object oTrue = true;<br />
Object oFalse = false;<br />
DataRow row;<br />
//CREATING OBJECTS OF WORD AND DOCUMENT<br />
Word.Application oWord = new Word.Application();<br />
Word.Document oWordDoc = new Word.Document();<br />
//DEFINE FILE<br />
openFileDialog.Filter = "Word Template File (*.dot)|*.dot|Word File (*.doc)|*.doc|All files (*.*)|*.*";<br />
//SETTING THE VISIBILITY TO TRUE<br />
oWord.Visible = true;<br />
//THE LOCATION OF THE TEMPLATE FILE ON THE MACHINE<br />Object oTemplatePath = openFileDialog.FileName;<br />
//ADDING A NEW DOCUMENT FROM A TEMPLATE<br />
oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);<br />
row = ((DataRowView)bs_results.Current).Row;<br />
foreach (Word.Field myMergeField in oWordDoc.Fields)<br />
String fieldtext = myMergeField.Code.Text;<br />
if (fieldtext.StartsWith(" NEXT"))<br />
if (bs_results.Position == bs_results.Count-1) break;<br />
row = ((DataRowView)bs_results.Current).Row;<br />
myMergeField.Code.Text = String.Empty;<br />
if (fieldtext.Contains("firstname"))<br />
if (fieldtext.Contains("lastname"))<br />
if (fieldtext.Contains("cellphone"))<br />
This is simple, and to the point, and works well. It has limitations though. It loops merge fields, so there are only so many labels created for example as are propagated in the .dot template file, as apposed to rows in the datatable.
How do I either propagate labels based on the row count, or do it completely different??
I basically have a results datatable with all the data I need, and would like to mail merge that data to labels in a Word template.
I am migrating from C++ to C#. The following compile error makes me confused. Suppose in interface there is a method called Abc which returns object, and in the implementation class, there is also a method called Abc, but the return type is List<int>, I think List<int> is already a type (derived type) of object, so no need to explicitly implement Interface.Abc again, but here is a compile error.
D:\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs(14,11): error CS0738: 'MyList.Foo' does not implement interface member 'MyList.IFoo.Abc()'. 'MyList.Foo.Abc()' cannot implement 'MyList.IFoo.Abc()' because it does not have the matching return type of 'object'.
Could anyone show me what is the rule I break here please?
class Foo : IFoo
public List<int> Abc()
Foo f = new Foo();
Let's say I have a resource broker, a 'lookup resource' event and a main program that will invoke the lookup resource event. All of these reside in decoupled modules, there may be only one resource broker and of course only one lookup event definition.
I created the following classes to implement the situation above:
staticvoid Main(string args)
However the output is not what I expected: the LookupResource event never gets called. That's understandable, since the ResourceBroker never gets referred in the executing code, it will not get instantiated. But what should I do to get the 'correct' output?
Creating a NoOp method in the ResourceBroker, and calling it in the Main function, works but it seems to me like an ugly hack. Am I missing something in the language keywords/features?
Thanks in advance
The Price of Freedom is Eternal Vigilance. -- Wing Commander IV
En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur.
(But the best thing God has created, is a New Day.)
-- Sigur Ròs - Viðrar vel til loftárása
Hmmmm... This is a bit of a tricky situation. Usually when I find myself in this situation, it means it's time to do a redesign. As a suggestion, you may want to make a BrokerManager that does all of the initialization for you, or pick an appropriate Broker class and have it take an instance of the other as a constructor argument. You can limit the instances that way, and you may be able to do away with the singleton pattern. Hope that helps somewhat.
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
My guess is that Type.GetTypeFromProgID is returning a null. Try seperating this out a bit and setting a couple of checks / breakpoints to try and find out more about what's going on:
Type acroapp = Type.GetTypeFromProgID("AcroExch.AcroExch");
Type acrodoc = Type.GetTypeFromProgID("AcroExch.AVDoc");
// Check that both existif ((acroapp == null) || (acrodoc == null))
thrownew Exception("Acrobat not installed on this system.");
// Now we can try to create instances
Acrobat.CAcroApp app = (Acrobat.CAcroApp)Activator.CreateInstance(acroapp);
Acrobat.CAcroAVDoc doc = (Acrobat.CAcroAVDoc)Activator.CreateInstance(acrodoc);
// Again check that we could create an instanceif ((app == null) || (doc == null))
thrownew Exception("Error initialising Acrobat");
// Now we should be able to load it
doc.Open(FileName, "Computing Mileage");
At least laying it out like this will tell you what's going wrong (or give you more of a hint).
If you see the first exception then check your TypeIDs for Acrobat, if you see the second then check the acrobat documentation is my only suggestion.