readonly

Assigning to static readonly field of base class

public class ClassA { public static readonly string processName; } pubic class ClassB : ClassA { static ClassB() { processName = "MyProcess.exe"; } } I am getting an error while compiling the above C# code. The error says -- "A static readonly field cannot be assigned to (except in a static constructor or a ...

Is it correct that "Developers have read-only access to the filesystem on App Engine"?

According to this Wikipedia article on Google App Engine: Developers have read-only access to the filesystem on App Engine. I have heard of App Engine apps that allow uploads and Google also sells additional storage - if so, wouldn't this statement appear to be incorrect? ...

[C#] NHibernate- Prevent deletion on a particular entity (i.e. make read-only)

Hi all How can I prevent NHibernate from deleting a single entity of a specific class? A programmatic way I am using at the moment entails checking for the entity's unique field "Name". Here's the scenario: I have a person and a group. The group can have persons and other groups. If the group named "Admins" is attempted to be deleted, ...

Putting a readonly title in a UITextField

How do I put readonly text inside a UITextField. For example, the "Name" and "Security" fields in the iPod touch "Other networks" settings contain, respectively, the words "Name" and "Security", with an editable area to the right. UITextField has a "placeholder" property but that disappears as soon as I type. ...

Is there a way to make readonly (not just private) automatic properties?

Automatic properties let me replace this code: private MyType myProperty; public MyType MyProperty { get { return myPropertyField; } } with this code: public MyType MyProperty { get; private set; } with a few changes here and there - but is there a way to replace this code: private readonly MyType myProperty; public MyType MyP...

How to make database field readonly in rails.

Hey folks, I have a database table with a certain field which should be impossible to update once it has been inserted to the database. How do I tell my model that it shouldn't allow updating of a certain field? Best Regards, x3ro ...

Why does resharper suggest readonly fields

Why is ReSharper suggesting readonly field for 'settings' in my example below? If I understand correctly, you should use readonly modifier if you change this field only in constructor, but in my example I change it also in another method in the same class. What am I missing? public partial class OptionsForm : Form { private Settings se...

serving a file from temp with rails on read only file system

I'm deploying my apps now to a server that has a read only file system. I was using a gem to make a zip file and randomly plopping it in /public somewhere. Now I can only write to tmp - how do I serve the user that file out of the tmp folder? ...

In C#, can a method return List such that clients can only read it, but not write to it?

Let's say I have a C# class: class Foo { private List<Bar> _barList; List<Bar> GetBarList() { return _barList; } ... } A client can call it: var barList = foo.GetBarList(); barList.Add( ... ); Is there a way to make the Add method fail because only a read-only version of _barList is returned? ...

Difference between ReadOnlyCollection string[] in the context of collection

IList<string> strList = new string[] { "Apple", "Mango", "Orange" }; IList<string> lst = new ReadOnlyCollection<string>(new[]{"Google", "MSN","Yahoo"}); In both cases i can not use "Add()" method for adding new items.then almost both declarations are same? ...

Open file read-only

In a C# WinForms app, I am using System.IO.Diagnostics.Process.Start(fileName) to open files. The type of file can be .doc, .docx, .xls, .xlsx, .csv, .pdf, or .txt. Is there any way to force these files to be opened read-only? ...

Is Core Data useful for readonly data too?

Hi, I'm creating an iPhone App and am wondering whether Core Data is better for readonly data than a SQLite database. It feels like the SQLite DB is the better choice, is that right? Can I even pre-fill the Core Data storage? Basically, I need like 3 tables with a bunch (up to 3000) of entities each. I then want to list the data in Tabl...

Having an uneditable, but selectable textbox

Hi, I'm making a web app. In it there are times when a form may be "read only". To simulate this with HTML, I have it so that all the (dynamically created) text boxes that contain content are disabled. This works fine enough, but if there is very much text and not all of it is visible at once(especially in multi-line boxes) then there is...

How do you make a property truly read only?

Take the following property: public string Foo { get; private set; } Using reflection, I can still set the value of this property from outside the owning class. Is there a way to prevent this? Removing the set accessor is not an option as it must be WCF friendly. ...

Is Shared ReadOnly lazyloaded?

Hello! I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? How about ReadOnly itself without the shared? Example: System.Type.Delimiter ...

Readonly wrapper of a LinkedList. HowTo?

Hello. .NET v2 When the List has a very useful (4 me) method AsReadOnly() the LinkedList does not have such a method. Is there a way to "quickly" interface an internal LinkedList to read only from the external code? ...

Open Word document with cursor disabled

Is there any way to create a word document where the cursor is invisible or disabled? After I save the document as read only, I want it to be opened like a pdf where even if a cursor is placed and typed, nothing is written on the document. ...

ActiveScaffold on Heroku's read-only file system?!!

ActiveScaffold apparently creates public/blank.html every time the server starts, even if that file already exists (so adding it to version control doesn't help). This is causing my application to fail to boot on Heroku, since they have a read-only file system. Can someone please tell me how to prevent this behavior or work around it s...

WCF: Exposing readonly DataMember properties without set?

I have a server side class which I make available on the client side through a [DataContract]. This class has a readonly field which I'd like to make available through a property. However, I'm unable to do so because it doesn't seem that I'm allowed to add a [DataMember] property without having both get and set. So - is there a way to ...

Why can't radio buttons be "readonly"?

I would like to show a radio button, have its value submitted, but depending on the circumstances, have it not editable. Disabled doesn't work, because it doesn't submit th value (or does it?), and it grays out the radio button. Readonly is really what I'm looking for, but for some mysterious reason it doesn't work. Is there some weird ...