What is the best way to assign a duration to particles?

I’m building a weather system into my latest prototype and tried to assign a length of time to particles.duration, however got the error
“Property or indexer `UnityEngine.ParticleSystem.duration’ cannot be assigned to (it is read only)”

If duration can’t be set by code directly (in C#), what is the best way to run particles for a set period of time?

Do you mean how long the particles live? Have a look at ParticleSystem.StartLifeTime.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour
{
	void Awake()
	{
		particleSystem.startLifetime = .5f;	
	}
}